Speed.csv:
date, Speed
1612852881000000000,10000
1612852882000000000,10000
1612852883000000000,10000
1612852884000000000,10000
1612852885000000000,10000
1612852886000000000,10000
1612852887000000000,10000
1612852888000000000,10000
1612852889000000000,10000
1612852890000000000,10000
1612852891000000000,10000
my code:
import time
import _csv
import pandas as pd
def convert_from_unix_stamp(raw):
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(raw) / 1000))
out=open("Speed.csv","r")
data=_csv.reader(out)
data=[(convert_from_unix_stamp(row[0]),row[1]) for row in data]
out.close()
a = pd.DataFrame(data)
print(a)
The Error:
File "linux_time_stamp_conversion_csv.py", line 20, in <module>
data=[(convert_from_unix_stamp(row[0]),row[1]) for row in data]
File "linux_time_stamp_conversion_csv.py", line 20, in <listcomp>
data=[(convert_from_unix_stamp(row[0]),row[1]) for row in data]
File "linux_time_stamp_conversion_csv.py", line 15, in convert_from_unix_stamp
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(raw) / 1000000))
ValueError: invalid literal for int() with base 10: 'date'
I know that the unix timestamp is too big for an intiger.
How exactly can I change that? Or rather how can I change the encoding?