Read CSV into table, but quoted text data contain new-lines
Show older comments
I am using "readtable" to read a CSV file into a table. The first row consist of column headings, and there are no row names. Some quoted text data contain new-lines, such as in this single string consisting of multiple lines:
"...some text</p><p>
</p><p>
more text...end text. "
The "readtable" function interprets the 2nd line above as a new record. None of the "readtable" parameters seem to be for recognizing newlines within a quote string as part of the sting itself. Is it possible to do this with "readtable"?
According to the following thread, it should be enough that the multi-line string be enclosed in quotes:
However, I get the error:
Error using readtable (line 216)
Reading failed at line 3. All lines of a text
file must have the same number of delimiters.
Line 3 has 0 delimiters, while preceding lines
have 20.
Note: readtable detected the following parameters:
'Delimiter', ',', 'HeaderLines', 0, 'ReadVariableNames', true, 'Format',
'%f%f%f%q%q%q%q%q%q%f%f%f%f%q%q%f%D%q%f%f%q'
Line 3 is the "</p><p>" in the sample above.
Accepted Answer
More Answers (0)
Categories
Find more on Data Import and Export 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!