How to ignore comment character from header/variable names line
Show older comments
Hi!
I'm importing a text file using readtable with row/column data and the first couple of lines are commented which includes the variable names. When I specify a line to get variable names from, it takes the comment character as a variable name and shifts my variable names by one column.
How do I have readtable ignore the comment character for that line or use other methods align my variable names correctly?
Thank you!
Code:
data_spray = readtable('spray.out', FileType='text', CommentStyle='#', VariableNamesLine=2);
Data File Snippet: spray.out
# column 1 2 3 4
# Crank tot_parcels spray_parcels liq_spray_mass
# (DEG) (drop+film) (drop) (kg)
#
-1.5200000e+02 0 0 0.0000000e+00
-1.5200000e+02 0 0 0.0000000e+00
-1.5188523e+02 0 0 0.0000000e+00
-1.5177080e+02 0 0 0.0000000e+00
-1.5163891e+02 0 0 0.0000000e+00
And this is what the imported table looks like in Matlab:

Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets 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!