Importing specific blocks of rows from file
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi - I am trying to import data that is distributed like this:
$ [marker]
[data, 12 columns, ~200k rows] ==> this is the data i want to import after the marker
[variable number of columns and rows]
$ [marker] -- Begins another set or Block
[data, 12 columns, ~200k rows] ==> this is the data i want to import after the marker
[variable number of columns and rows]
================================================ This is a sample of the Data
$ 33, 1.000000e+02 ================>> [marker, ID, Timestep]
2.16774183865960e+03, 2.17155003512612e+03, 2.16743573002462e+03, 2.16360580614394e+03, 2.16346774309583e+03, 2.16053340274031e+03, 2.16167864768523e+03, 2.15753149798806e+03, 2.15897246203298e+03, 2.15326408153715e+03, 2.15120660138186e+03, 2.14757146384007e+03,
2.14513985262235e+03, 2.13873969626383e+03, 2.14152811665221e+03, 2.13484192927493e+03, 2.13228154897046e+03, 2.12820999931608e+03, 2.12566138709717e+03, 2.12126497354156e+03, 2.12263910079983e+03, 2.11778548748744e+03, 2.11746577100915e+03, 2.11491733662709e+03,
I tried using 'textscan' but it only imports the first block of ~200k rows, how can I have it move to the next block ?
Dac = fopen('Rat10m_sat_asc3h2.txt','r');
hDat = textscan(Dac,'%f %f %f %f %f %f %f %f %f %f %f %f','Delimiter',',');
thanks for comments, G
0 Kommentare
Antworten (1)
Anushi1998
am 4 Jul. 2017
You can import the whole file and make an another variable by selecting only specific rows
file=importdata('file_name.txt');
rows=[...] %desired rows
cnt=10
for ii=1:length(rows)
cnt=cnt+1;
data(cnt,:)=file(rows(ii),:);
end
Siehe auch
Kategorien
Mehr zu Block Libraries 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!