heartandsole.Activity.from_gpx

classmethod Activity.from_gpx(file_obj)[source]

Construct an Activity from a .gpx file.

Parameters

file_obj – Any file-like object accepted by activereader.Gpx

Returns

Activity

Examples

Provide a file path:

>>> act = Activity.from_gpx('my_activity.gpx')

Provide a raw string of bytes:

>>> with open('my_activity.gpx', 'rb') as fb:
...   raw_data = fb.read()
>>> act = Activity.fom_gpx(raw_data)

Provide a string (no encoding info):

>>> with open('my_activity.gpx', 'r') as f:
...   xml_string = f.read()
>>> act = Activity.fom_gpx(xml_string)