Read data from CSV that contains multiple tables one after the other vertically

Hello,
I would be really thankful if someone an help me with this. Please do mind I'm relatively new to Matlab. This might be easy to do but I can't seem to find how to do it.
I have a large csv file (26000+ rows) that contain multiple tables one after the other. each table has a name stated in the row after "[Name]". and the data corresponding to that table is given in the rows following "[Data]". Please see the attached image. The data are times vs velocities. The times of each table is same. I need to get the data into one matrix, which would have the data as time in 1st column, and the velocities corresponding to the times for each point in the following rows. i.e. 1st column time, 2nd column velocity of point 0, 3rd column velocity of point 1, 4th column velocity of point 2 etc. The tables are not in the order of the points. So the name should be read and assigned to the particular pint, if that makes any sense.
I would be really thankful if someone can help me with this please.
I have attached a sample data set also.
Thanks in Advance,
Dilshan.

6 Comments

hello
I worked hard for you today !!
attached the main script (can loop over multiple csv input files ) + a subfunction to process each individual csv file.
tested on your file, I send my xls output file
hope it fullfills your dreams ! :)
all the best
Oh my god. Thank you very much. This is much more than I hoped for.
I will test it quickly and Will post an update.
Thanks again Mathieu.
glad it helped !!
please "accept" my answer so my teacher will give an image for my homework ! :)
Hi Mathieu, your comment is in comments section and can't be accepted as an answer.
Update:-
Mathieu, This works like a charm.
Very easy to read and well commented and explained code. Looks like a lot of work. Can't thank you enough.
As Mario has stated, your Answer is posted as a comment and I cannot accept it unfortunately. Kindly post it as an answer so I can mark it.
Best of luck to your future!!
Regards.

Sign in to comment.

 Accepted Answer

hello
I worked hard for you today !!
attached the main script (can loop over multiple csv input files ) + a subfunction to process each individual csv file.
tested on your file, I send my xls output file
hope it fullfills your dreams ! :)
all the best

More Answers (0)

Products

Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!