Is there a Row limit when transfering a matlab table to CSV file?

4 views (last 30 days)
I have a MATLAB table of 8 columns and 246 312 ROWS. I tried to transfer the MATLAB table to CSV in order to be able to use it in STATA cause I have a MAC and the xlwrite or any other function to transfer to an excel file from MATLAB sends an error mess. So i am using the matlab function:
>> writetable(A, 'filename.csv', 'Delimiter',' ,' ,'QuoteStrings', true).
I get a CSV file with all the 8 columns but only a part of the rows, i get 139 521 instead of the 246 312 rows.
WHY???
How can i get all the rows in?
I tried transferring the CSV file to EXCEl to double check if excel was gonna pick it up, but EXCEL too only gets 139 521.
How can i do to correct that?
PS: My EXCEL version is a MAC version 2011
Thank you for your help.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Oct 2016
I tested with
A = array2table( randi([0 255], 246312,8,'uint8') );
writetable(A, 'filename.csv', 'Delimiter',',' ,'QuoteStrings', true)
Note that I had to modify the delimiter from ' ,' to ',' alone as writetable only permits a single character for the delimiter (unless a \ escape is used, and even then it has to format into a single character.)
>> !wc filename.csv
246313 246313 7035422 filename.csv
So it got the right number of lines (the extra one is the header)
I opened it with Microsoft Office 2011 on my Mac; all of the lines were there.

More Answers (1)

Massimo Zanetti
Massimo Zanetti on 7 Oct 2016
Depending on Office version, there are limitations in the maximum number of rows Excel can load. To really know how many rows the CSV file has, open it with another software that does not have limitations. For example: http://www.delimitware.com/
  9 Comments
Massimo Zanetti
Massimo Zanetti on 8 Oct 2016
Edited: Massimo Zanetti on 8 Oct 2016
Yes, you are right. But, as far as Amira says xlswrite didn't work.. That is way I proposed another option (which is indeed the Matlab built-in function to write CSV).
Walter Roberson
Walter Roberson on 8 Oct 2016
xlwrite() from the File Exchange and xlswrite() from MATLAB are not defined in table() data objects.
xlswrite() of a cell containing strings to a .csv file is not supported in Basic mode, which the user would be restricted to because they are on a Mac.
table2cell() followed by xlwrite() from the File Exchange might work. (I do not have the poi_library installed at the moment so I cannot tells at this time.)

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!