Readtable() Skipps last rows of csv
1 view (last 30 days)
I have some issues with importing and exporting data.
I am summerizing some measurment data in one script which then saves the summarized data in a csv file for easy sharing (using writetable(table, filename).
Now I would like to import this data to work with it again and therefore I try to import it using readtable(filename).
The issue ist, that I export a 392x10 table and it only imports a 323x10 table. It just skipps the last 70 rows somehow.
When I open the csv-file in excel I can see that the export worked fine.
filename = 'measurementdata.csv';
Import said file in different script
table2 = readtable('measurementdata.csv');
%Access colums by name
temps = unique(table2.targTemp);
volts = unique(table2.targVlt);
curr = unique(table2.targCurr);
I have attached the measurmentdata.csv file
Star Strider on 1 Jul 2022
Edited: Star Strider on 1 Jul 2022
If you are using the unique function before writing the output file, it could be deleting several entries. Also, the correct approach is likely to be:
table2u = unique(table2, 'rows');
to avoid scrambling the individual columns (variables).
I have not checked by looking at it in Excel, however it appears to be read correctly (as a (392x8) table) in R2022a —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1052370/measurementdata.csv', 'VariableNamingRule','preserve')
LastRow = T1(392,:)
Check to be sure all the updates to R2017b are downloaded and installed, since there could be a bug that was subsequently fixed. (I no longer have R2017b installed here, so I cannot test it.)