How can I get the text instead of NaN when using import options for readtable?
Show older comments
Dear all,
I'm using readtable to import data from an open inventor file. The file has some delimited text and point cloud data as x,y,z coordinates that I need.
The file for example looks like this:

My code so far only separates all coordinates from the open inventor file.
To separate them I use readtable with following import options:

But now I want to:
- Import the open inventor file as a table (like I do already)
- Find a range that can be defined by a first/last row with a specified text
- Remove all NaN rows in this range to separate the coordinates
- Use finally a n-rows by 3-columns table to continue processing
My problem now:

If I convert the file to a table with the import options from above, I cannot search for the range boundaries I need, because every text element is converted to NaN. How can I get back the original text and search for the specified rows including text?
attached is a text file that is identical to the open inventor file. If you try to reproduce my code, please rename the extention to ".iv" to reproduce the same behaviour.
I'm using Matlab 2020b.
Thank you very much in advance!
3 Comments
dpb
on 26 Nov 2020
The header info is not compatible with reading as a table; may as well forget about even trying to do that; there's nothing but grief to be gained heading down that path.
Open the file and read line by line looking for the info you want...
fgetl is about as easy as there is for the purpose.
Florian Teriet
on 27 Nov 2020
dpb
on 16 Dec 2020
I suspect you'd be surprised at relative timing between fgetl and calling detectImportOptions, readtable and table2array twice
Answers (1)
Prashik Shende
on 16 Dec 2020
0 votes
Categories
Find more on Data Type Conversion 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!