Reading a string datafile line by line
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all, I've been trying to read strings from a txt file (a replay script from ICEM actually) line by line but I've been unable to so far.
I want to obtain a string array that each element includes one of the lines of the datafile.
the text file looks like this:
_'ic_boco_solver
ic_boco_clear_icons
ic_csystem_display all 0
ic_csystem_set_current global
ic_boco_nastran_csystem reset
ic_undo_group_end
ic_set_global geo_cad 0 toptol_userset
ic_set_global geo_cad 0.0005 toler
ic_undo_group_begin
ic_geo_new_family GEOM
ic_boco_set_part_color GEOM
ic_point {} GEOM pnt.00 -10,10,0'_
I have only managed to either get each all the text in the same element:
_ic_boco_solveric_boco_clear_iconsic_csystem_display_
or each character separately like this:
_I
c
_
b
o
c
o
_
s
o_
or to get chunks that are separated by empty spaces like this:
_'ic_boco_solver'
'ic_boco_clear_icons'
'ic_csystem_display'
'all'
'0'
'ic_csystem_set_current'
'global'
'ic_boco_nastran_csystem'_
, but I could not get the whole line and only the line.
that was using respectively:
temp1=textscan(fid,'%c')
or
temp2=dataread('file','text.txt','%c')
or
temp2=dataread('file','text.txt','%s')
Every line starts with 'ic_'. Maybe that could help?
Thank you!
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur String Parsing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!