Loading every n-th column of a csv with varying formats in row using textscan
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Moritz P.
il 21 Mag 2015
Risposto: Star Strider
il 21 Mag 2015
Hi, i am trying to load a csv file with semicolon (;) delimiter.
Example:
150501;190722;ms_since_start=;30001276;temp=;31.97;IT=;147753;spec num=;1000;(here i have 512 floating number repetitions and ';;' to indicate the end of line)
this pattern repeats for 1000 rows.
I have been trying to use textscan but only get empty cells with the following code
formatSpec = ['%s%s%*s%*s%*s%*s%*s%*s%*s%*s%*s' repmat('%f', [1,512]) '%*[^;;]']
M = textscan(dirtmp, formatSpec, 'Delimiter', ';')
The goal is to get the first 2 columns, skip 9, get the remaining 512 columns and repeat this for 1000 rows.
Any help is highly appreciated
0 Commenti
Risposta accettata
Star Strider
il 21 Mag 2015
You may need to change the last part of your ‘formatSpec’ line deleting the '%*[^;;]' and including 'MultipleDelimsAsOne',1 and 'EndOfLine','\r\n' or perhaps something else if you have a different end-of-line indicator.
Also consider this as the first part of your ‘formatSpec’:
'%f;%f;ms_since_start=;%f;temp=;%f;IT=;%f;spec num=;%f'
No promises these will solve your problems, but I would experiment with those and other options until I got it working.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Import from MATLAB 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!