i have provided one zip file with raw file in the name of"CODG0240.11I"and an output format file in the excel format.how can i extract the data from the raw file in the form of given output format.please provide the code.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
please provide the code
10 Kommentare
Walter Roberson
am 29 Jun. 2018
Are you using Mac, or Linux? If so you can use "uncompress" to open the .Z file. If you are using Windows see https://fileinfo.com/extension/z and https://www.ncbi.nlm.nih.gov/Ftp/uncompress.html
I will wait for you to confirm you are able to get the text version of the .Z file before describing the text processing code.
Antworten (1)
Walter Roberson
am 2 Jul. 2018
filename = 'CODG0240.txt';
S = fileread(filename);
parts = regexp(S, '.*END OF TEC MAP.*', 'split', 'dotexceptnewline');
if isempty(parts{end}); parts(end) = []; end
parts = cellfun(@(str) regexprep(str, '^.*EPOCH OF CURRENT MAP[^\n]*', ''), parts, 'uniform', 0);
Now parts is a cell array of character vectors. Each character vectors is one epoch. The character vector contains repeated blocks of the form
87.5-180.0 180.0 5.0 450.0 LAT/LON1/LON2/DLON/H
13 13 13 13 13 13 13 13 13 13 13 13 13 12 12 12
11 11 11 10 10 9 9 9 8 8 7 7 6 6 6 5
5 4 4 4 3 3 3 3 3 3 2 2 2 2 3 3
3 3 3 4 4 5 5 5 6 6 7 7 8 9 9 10
10 10 11 11 12 12 12 13 13
with no header before that, and no trailing line after that.
Now,
fmt = ['%.1f%.1f%.1f%.1f%.1f%*s', repmat('%f',1,73)];
result = cellfun(@(P) cell2mat(textscan(P, fmt, 'collect', true, 'whitespace', ' \n')), parts, 'uniform', 0);
Result will now be a cell array, each entry of which corresponds to one epoch in the file. Each cell array entry will be a numeric array which will have one row for each block that looks like the above -- that is, one row for each latitude longitude combination. The row will start with 5 entries corresponding to the 87.5-180.0 180.0 5.0 450.0 type of information. The string is not stored as it is the same in all blocks. The next 73 entries in the row are the 13, 13, ... etc through to the 12 13 13 -- those 5 numeric lines are bunched together. So that is 5 entries of header information and 73 numbers, total 78 per row.
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!