tcgoetz / GarminDB

Download and parse data from Garmin Connect or a Garmin watch, FitBit CSV, and MS Health CSV files into and analyze data in Sqlite serverless databases with Jupyter notebooks.
GNU General Public License v2.0
1.09k stars 137 forks source link

___Analyzing Data___ TypeError: '<' not supported between instances of 'int' and 'NoneType' #234

Open ItzFender opened 2 months ago

ItzFender commented 2 months ago

GarminDB version: 3.6.0 Python version: 3.12.4

Command: garmindb_cli.py --all --download --import --analyze --latest

<- Downloads data Removed for brevity ->

Error:

___Analyzing Data___
Summary Tables Generation:
Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Programs\Python\Python312\Scripts\garmindb_cli.py", line 368, in <module>
    main(sys.argv[1:])
  File "C:\Users\username\AppData\Local\Programs\Python\Python312\Scripts\garmindb_cli.py", line 355, in main
    analyze_data(args.trace)
  File "C:\Users\username\AppData\Local\Programs\Python\Python312\Scripts\garmindb_cli.py", line 248, in analyze_data
    analyze.summary()
  File "C:\Users\username\AppData\Local\Programs\Python\Python312\Lib\site-packages\garmindb\analyze.py", line 192, in summary
    for year in sorted(list(set(Monitoring.get_years(self.garmin_mon_db) + Activities.get_years(self.garmin_act_db)))):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'int' and 'NoneType'
ItzFender commented 2 months ago

I ended up finding issue #163 which pointed me in the right direction.

I had 16 rows in my activities table that were completely blank.

View: select start_time from activities where start_time IS NULL;

Delete: DELETE from activities WHERE start_time IS NULL;

I don't have a lot of experience with python so I may be way off base, but could you filter out null or empty datetimes in the get_years() method/function?