Extract data from a text file
Show older comments
Hi, I have a text file that contains specific parameters, I want to create standard functions, to extract these parameters and write them according to the standard used in the image below, I want to create 3 functions 1- load_materials 2- load_points 3-load_polygones all future text files should have the same format, see the attached image thanks for help

6 Comments
Paolo
on 10 Jul 2018
Please attach your file
ourimchi omar
on 10 Jul 2018
dpb
on 10 Jul 2018
Read the whole file and do the selection in memory...if you read into table and create an auxiliary variable based on the existence of the matching string for the three classes as a categorical variable, then the grouping and conversion becomes trivial via
findgroups
splitapply
and/or
varfun
ourimchi omar
on 10 Jul 2018
KSSV
on 11 Jul 2018
Are the number of lines always fixed? Or it will change?
dpb
on 11 Jul 2018
I misunderstood the initial Q? thinking you had the two columns and just needed to split; not to build the RH column. For the latter, store the base text lines in a lookup table and then have to read the input file knowing it's composition. You can again read that full file into memory (cell array) and walk through it rather than reading record-by-record or you can read the counted number of records after reading the various counts; your choice.
Answers (0)
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!