How to import data of the form [variable name]Data[-]
Show older comments
I want to read data and variables from a specially formatted file as MATLAB variables. Preferably into a structure.
I am looking for the best approach for a quick solution. unfortunately I am stuck. Maybe someone can give me a helpful hint.
Data in the file have the strucktur:
[variable name]
data
[-]
[variable name]
x1 y1
x2 y2
x3 y3
[-]
A shortened example file:
Instrument Name
File Format Version
[DateTime]
1643810991
[-]
[GenParams]
[CableID]
[-]
[FiberID]
[-]
[FiberType]
0
[-]
[Settings]
[Wavelength]
1
[-]
[PulseWidth]
7
[-]
[End]
35.000
[-]
[Start]
0.000
[-]
[DataPoints]
0.011 -5.000
0.011 -5.000
0.036 -5.000
0.061 -5.000
[-]
6 Comments
Rik
on 12 Feb 2022
What have you tried so far?
It seems like you should split your text on the [-] lines. How did you try to parse each of those segments to struct fields? It looks to me like some have 2 names or don't have data. How do you want to deal with those?
Simon Dengler
on 14 Feb 2022
Rik
on 14 Feb 2022
Your data is much too mixed to read as a csv. That works best if you have a single array (with or without some fixed number of header lines).
AndresVar
on 14 Feb 2022
Before you spend a long time to make a parser, check if your instrument manufacturer has a way to convert or export the data in another more familiar format. Google, maybe someone already parsed it.
Simon Dengler
on 14 Feb 2022
Stephen23
on 14 Feb 2022
Accepted Answer
More Answers (0)
Categories
Find more on Data Import and Analysis 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!