Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Csvwrite with numbers larger than 7 digits

So, I have a file that's designed to parse through a rather large csv file to weed out a handful of data points. Three of the values (out of 400,000+) within the file is listed below:

Vehicle_ID  Frame_ID    Tot_Frames  Epoch_ms    Local_X
2           29          1707        1163033200  8.695
2           30          1707        1163033300  7.957
2           31          1707        1163033400  7.335

What I'm trying to do here is to take previously filtered data points like this and plug it into another csv file using csvwrite. However, csvread will only take in the Epoch_ms in double precision, storing the value as 1.1630e+09, which is sufficient for reading, as it does maintain the original value of the number for use in MATLAB operations.

However, during csvwrite, that precision is lost, and each data point is written as 1.1630e9.

How do I get csvwrite to handle the number with greater precision?

like image 294
panoptical Avatar asked Feb 20 '13 04:02

panoptical


1 Answers

Use dlmwrite with a precision argument, such as %i. The default delimiter is a comma, just like a CSV file.

dlmwrite(filename, data, 'precision', '%i')
like image 188
shoelzer Avatar answered Oct 20 '22 22:10

shoelzer