readtable command for csv file
9 views (last 30 days)
Show older comments
Hi,
I am having an issue while reading the csv file into MATLAB. The size of the csv file is greater than 100000KB. When I try to read it through the readtable command in MATLAB, it starts skipping some rows in the csv file and gives the following error
Error using readtable (line 223)
Reading failed at line 15473. All lines of a text file must have the same number of
delimiters. Line 15473 has 1 delimiters, while preceding lines have 515.
Note: readtable detected the following parameters:
'Delimiter', ',', 'ReadVariableNames', false, 'Format',
0 Comments
Answers (3)
Cris LaPierre
on 12 Feb 2021
Without seeing what lines 15473 looks like compared to, say, line 1, it's really hard to add to what the error message is already telling you. It would appear the format of your data changes.
You could try looking into some of the options in detectImportOptions. Perhaps "MissingRule","omitRow"? Or "ImportErrorRule","omitRow"?
0 Comments
Waqas Siddique
on 12 Feb 2021
7 Comments
Walter Roberson
on 12 Feb 2021
See Cris's suggestion to use import options to see the error handling.
Jeremy Hughes
on 12 Feb 2021
Try this,
opts = detectImportOptions(filename)
T = readtable(filename,opts)
I think the import options based default reading behavior will work for you. (R2016b or later)
If you're in a MATLAB earlier than R2016b readtable won't be able to handle this file. You will need to read line by line, and parse each line separately.
0 Comments
See Also
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!