Readtable() Skipps last rows of csv
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tim Rothhaupt
le 1 Juil 2022
Commenté : Star Strider
le 4 Juil 2022
Hello there,
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.
%Script 1
...
filename = 'measurementdata.csv';
writetable(table,filename);
Import said file in different script
%Script 2
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
0 commentaires
Réponse acceptée
Star Strider
le 1 Juil 2022
Modifié(e) : Star Strider
le 1 Juil 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.)
.
4 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!