fjxmlzn / FindMyHistory

Track your Apple devices and look up their past location, battery levels, and more
MIT License
308 stars 34 forks source link

Convert2GPX #25

Open qwertyqwertyasdfasdf opened 4 months ago

qwertyqwertyasdfasdf commented 4 months ago

I have made a script to convert the csv into gpx files. You have to add the date as an argument in the terminal. Ex: python3 csv_to_gpx.py 2024-07-10

from gpx_converter import Converter
import pandas as pd
import sys

path = str(sys.argv[1])
df = pd.read_csv(path + '/CSV_FILE_NAME.csv')
df['location|timeStamp'] = df['location|timeStamp'] + 7200000
df['location|timeStamp'] = pd.to_datetime(df['location|timeStamp'], unit='ms',utc='true')
df.to_csv('CSV_FILE_NAME_%s.csv' % path)

print(df['location|timeStamp'])

Converter(input_file='CSV_FILE_NAME_%s.csv' % path).csv_to_gpx(lats_colname='location|latitude',
                                                            longs_colname='location|longitude',
                                                            times_colname='location|timeStamp',
                                                            output_file='CSV_FILE_NAME_%s.gpx' % path)