Textscan is only reading the first two lines of my CSV file, how can I fix this?
2 views (last 30 days)
Show older comments
Bruno Rodriguez
on 28 Sep 2015
Commented: Bruno Rodriguez
on 28 Sep 2015
I have a CSV file with 18 columns and 27,915 rows called 'SenoiaRWIS.csv'. I have attached a CSV file containing the first 5 lines of SenoiaRWIS for reference.
I have tried to read in each column with a separately specified format using textscan as follows:
fid = fopen('SenoiaRWIS.csv'); data = textscan(fid,%f%s%s%f%f%f%f%f%f%f%f%f%f%s%f%f%f%s, 'Delimiter', ',');
However, this has returned a 1x18 cell where each cell contains just 2 entries, the entries being those of the first two rows of the file. Does anyone have any idea why it stops at the second row?
Thank you for your help
0 Comments
Accepted Answer
Walter Roberson
on 28 Sep 2015
The 10th field is expected to be numeric, %f format, but the 10th field of your second line is \N which is a string. The reading would stop at that point.
I suggest you look at the TreatAsMissing option.
More Answers (0)
See Also
Categories
Find more on Text Files 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!