how to extract data from a range of (slightly) varying csv files

1 view (last 30 days)
Hi there,
I'm trying to write a function that will import and plot relevant data from a csv file. This is because for every file I have, there is some settings above the data that vary in length. So for example; sometimes the data starts at row 20 and sometimes 50 . Also the length of the data column varies. The columns from which I want to extract data is always the same.
How can matlab recognise from what point to take the data?
I think this should be possible as the settings only take 2/3 columns and the data is 5 or 6 columns wide, so you can 'see' where the data starts if you let matlab 'search' in the 6th column if that is possible.
Thank you in advance!
Geard
  7 Comments
Nikhil Negi
Nikhil Negi on 21 May 2018
Hello Gerard,
from observing all the files you provided it looks like all your required data is between the < segment1 > and < /segment1 > of the text file. is it the case with all the files or just the 3 you provided.
if its the same with all the files you can use these strings as "milestones" to identify the data and then extract them.
Guillaume
Guillaume on 21 May 2018
Stephen is right that the files are absolutely not csv. The extensions are very misleading.
However, while structurally similar to XML, the files are also not valid XML and I suspect that an XML parser will choke on them (e.g. lines like Limits2,Direction=< will wreak havoc with the XML parsing)

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!