문제

I'm importing some data from a CSV into Mathematica. The first few lines of the CSV look like this:

"a_use","tstart","tend"
"bind items on truck to prevent from flying off",1328661514469,1328661531032
"hang laundry on",1328661531035,1328661541700
"tie firewood with",1328661541702,1328661554940
"anchor tent",1328661554942,1328661559797

Mathematica handles this almost perfectly:

data = Import["mystuff.csv"]

The problem is that those big timestamps get converted into scientific notation, and the precision is lost:

In[283]:= data[[2,2]]
Out[283]= 1.32866*10^12

As you can see, even though 1328661531035 is not the same as 1328661541700, the imported data is no longer precise enough to tell the two apart, since both get imported as 1.32866*10^12. I know Mathematica can handle integers of arbitrary length, so how can I get it to import these numbers as (large) integers instead of converting them into this lossy scientific notation?

도움이 되었습니까?

해결책

What version are you using? No problem on Mma 8.0.1.

enter image description here

If you are creating the CSV file in Excel set the format of the timestamps to Number with zero decimal places (via More Number Formats...)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top