How can I read a .txt file with out the header?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
cob
il 6 Ott 2014
Modificato: Azzi Abdelmalek
il 7 Ott 2014
Hi, I have several files for a different points. The file name is a number like this:
C:\Users\cborba\Documents\Tides\10513.txt
I need get the latitude of each one(line 4 from the header) and read the file without the header (starting from line 12). How can I do this?
Thanks
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 6 Ott 2014
fid = fopen(C:\Users\cborba\Documents\Tides\10513.txt');
line1 = fgetl(fid);
res=[];
while ischar(line1)
res{end+1,1} =line1
line1 = fgetl(fid);
end
fclose(fid);
latitude=regexpi(res{4},'(?<=LATITUDE).+','match')
data=res(12:end)
2 Commenti
Azzi Abdelmalek
il 7 Ott 2014
Modificato: Azzi Abdelmalek
il 7 Ott 2014
fid = fopen('10513.txt');
line1 = fgetl(fid);
res=[];
while ischar(line1)
res{end+1,1} =line1
line1 = fgetl(fid);
end
fclose(fid);
latitude=regexpi(res{4},'(?<=LATITUDE).+','match')
data=res(12:end)
date=cellfun(@(x) x{1},regexp(data,'.{16}','match'),'un',0)
hight=str2double(cellfun(@(x,y) regexp(x,['(?<=' y ').+'],'match'),data,date))
Più risposte (1)
the cyclist
il 6 Ott 2014
One possibility is to use the Import Tool, available on the Home tab of the Toolstrip of the Command Window. This allows you to specify the exact spreadsheet locations you want to import.
0 Commenti
Vedere anche
Categorie
Scopri di più su File Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!