mixpanel-utils icon indicating copy to clipboard operation
mixpanel-utils copied to clipboard

Incorrect output filenames for filenames with periods

Open KaleyWhite opened this issue 1 year ago • 0 comments

When request_per_day is True and the base output_file name (without the extension) contains periods, the output filenames are incorrect. If the period is in a directory name in the path, then export_eventsraises a FileNotFoundError.

mputils = MixpanelUtils(...)
params = {'from_date': '2024-01-12', 'to_date': '2024-01-13'}
mputils.export_events('test.json', params=params, request_per_day=True)  # Intended behavior
mputils.export_events('test.test.json', params=params, request_per_day=True)  # Export filenames in the format 'test_YYYY-MM-DD.text' instead of 'test.test-YYYY-MM-DD.json'
mputils.export_events('dot.directory/test.json', params=params, request_per_day=True)  # FileNotFoundError: dot_2024-01-12.directory/test

The bug occurs because export_events generates the new filename by splitting along the first instead of the last period in output_file.

KaleyWhite avatar Jan 13 '25 15:01 KaleyWhite