Info
This question is closed. Reopen it to edit or answer.
textscan scuppered by '\n' mid entry
1 view (last 30 days)
Show older comments
I have a csv file that annoyingly has some string entries that have newlines within the entry. Therefore when textscan comes across this entry it thinks it has reached the end of the row and tries to start a new one, where it halts scanning.
I tried to skip this field using %*s which doesn't work. Is there a way to ignore the '\n' signifier in between delimiters?
0 Comments
Answers (1)
Image Analyst
on 25 Jun 2014
You can pre-process the file. Pseudocode:
open file
while not EOF
read a line with fgetl
count commas
if commas not the expected amount
read next line
stitch both lines together
count commas again.
if commas not the expected amount, it's an error
Alert user via warndlg
end
end
write line to output file
end
2 Comments
Image Analyst
on 25 Jun 2014
I didn't understand. Are you saying that you have two commas in a row or missing or extra commas? Please give an example of that type of line.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!