csvwrite is storing wrong number
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abolfazl Taghribi
am 25 Jan. 2019
Bearbeitet: dpb
am 28 Jan. 2019
I'm using "csvwrite" command for storing a 2d matrix with size 104937*1810. Is there any limitation on this command or csv file? The produced file is 670 MB but in each stored row there are exactly 5 numbers which are not the same as matrix in the matlab. All numbers are int32 and the wrong numbers are in different colomns in each row.
1 Kommentar
Walter Roberson
am 25 Jan. 2019
Would it be possible to xlswrite() or writetable() to a .xlsx file and attach that for us to test with?
Also which release are you using?
Akzeptierte Antwort
dpb
am 26 Jan. 2019
Bearbeitet: dpb
am 26 Jan. 2019
>> tstary=int32(randi(2^31,104937,1810));
>> whos tstary
Name Size Bytes Class Attributes
tstary 104937x1810 759743880 int32
>> tstary(1:3,1:5)
ans =
3×10 int32 matrix
1186639717 717774140 2035668545 471416973 522550194
2056308186 151423171 131112521 1937130594 1414722413
1917344954 1185569608 203068410 614639920 243357862
>> csvwrite('tstary.csv',tstary)
Content of tstary.csv from file viewer...
1.1866e+09,7.1777e+08,2.0357e+09,4.7142e+08,5.2255e+08,1.1246e+09,1.5343e+09,3.2607e+08, ...
2.0563e+09,1.5142e+08,1.3111e+08,1.9371e+09,1.4147e+09,7.5605e+08,7.9947e+08,6.188e+08, ...
1.9173e+09,1.1856e+09,2.0307e+08,6.1464e+08,2.4336e+08,9.5385e+08,1.0362e+09,2.0352e+09, ...
...
The content is exactly what the documentaion for csvwrite says it will be--the data in %g format with a maximum of 5 digits of precision.
The help there indicates to use dlmwrite with optional precision argument, but for such a large file, using a text format is absurd way to store/move/transport data. Use stream or some other form instead.
But, csvread is working as expected.
3 Kommentare
dpb
am 26 Jan. 2019
Bearbeitet: dpb
am 28 Jan. 2019
I misunderstood initially, too, I think, but decided that probably it was a case of the symptom not being recognized as to cause that produced a mistaken interpretation of the cause of the difference and that led to asking the wrong question--or wording the question to be about the wrong problem.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!