Importing specific blocks of rows from file
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Anushi1998
il 4 Lug 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
Vedere anche
Categorie
Scopri di più su Block Libraries 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!