Data in the Sleep as Android app comes in a CSV file that is very difficult to process with the aim of examining it because each sleep record is of variable length. It's made up of header rows and values rows.
This project is designed to process sleep data in its raw format and output it into a more friendly format.
Right now, this just takes a CSV file from the Sleep as Android app and converts it into a JSON file, but future goals are to allow for more options and move on to sleep data from other systems, including CPAP machines.
Original Sleep as Android CSV file:
Script output:
Resulting JSON file:
Using this is easy! From the main folder of this repository, simply create the path /sleep-as-android/csv/
and place your sleep-export.csv
file there.
Alternatively, you can change the relative file path in main.py
. You can do this for the location of the CSV file, and specify where the JSON files should go as well (don't include a forward slash after the directory name).
- 1.0.4
- FIX: Time zones are now added when converting Unix timestamps into datetimes for events.
- 1.0.3
- CHANGE: Raise an exception if the CSV file is not detected as being a valid Sleep as Android export.
- 1.0.2
- FIX: Errors when running on a web server caused by attempt to subscript types such as
dict[str, str].
- ADD: Ability to specify output directory for JSON files.
- FIX: Errors when running on a web server caused by attempt to subscript types such as
- 1.0.1
- CHANGE: Update of README.
- 1.0.0
- Original project launch.
Language: Python 3.9.7
Handles files: CSV, JSON
Distributed under the GNU GPL v3 license. See LICENSE
for more information.