This function takes a filename as input and removes characters that are not allowed in Windows filenames (such as /, , :, *, ?, ", <, > and |).
filename (str) - The input filename.
A cleaned filename with invalid characters replaced by underscores.
This function converts latitudeE7 and longitudeE7 values, which are in a format with seven decimal places, to standard latitude and longitude format.
e7_value (int) - The latitudeE7 or longitudeE7 value.
The latitude or longitude value in standard format.
This function maps activity types to emojis using the EMOJI_MAPPING constant.
text (str) - The activity type text.
The corresponding emoji for the given activity type or '❓' if no mapping is found.
This function converts a timestamp string to a 24-hour time format.
timestamp_str (str) - The timestamp string in ISO format.
The timestamp string in 24-hour time format (HH:MM:SS).
This function creates a temporary directory using Python's tempfile.TemporaryDirectory and returns the temporary directory object.
A temporary directory object.
Generates frontmatter for Markdown files based on the provided configuration and directory name.
- config (dict): A dictionary containing configuration settings, including the frontmatter settings.
- dir_name (str): The name of the directory used to generate frontmatter values.
- str: A string containing the generated frontmatter for the Markdown file.
The function checks the configuration settings to determine which frontmatter fields to generate. It handles special formatting for the "title" and "tags" fields. Adding your own key value pairs may not work.
"output_frontmatter_toggle": True,
"output_frontmatter": {
"title": "%Y-%m-%d-%A",
"tags": "LocationHistory,GoogleTakeout"
}
---
title: 2023-10-05-Thursday
tags:
- LocationHistory
- Other
---
This function generates a Markdown table with two header cells (h1 and h2) and two body cells (b1 and b2).
h1 (str) - The content for the first header cell. h2 (str) - The content for the second header cell. b1 (str) - The content for the first body cell. b2 (str) - The content for the second body cell.
A Markdown table string.
This function splits JSON data into day-specific folders within a temporary directory based on the start timestamp of activities or place visits. This is important because Google provides JSON files containing a whole month's worth of data.
input_folder (str) - The folder containing JSON data to be split. temp_folder (str) - The temporary directory where the data will be split into day-specific folders.
merge_json_data(temp_folder, output_folder, iframe_base_url, main_folder_name, year_format, month_format, day_format)
This function merges JSON data into Markdown files, organized in a folder structure based on the provided parameters. It also formats the data and generates Markdown tables for activities and place visits.
temp_folder (str) - The temporary directory containing the split JSON data. output_folder (str) - The root output folder where the Markdown files will be created. iframe_base_url (str) - The base URL used to generate iframes for location data. main_folder_name (str) - The name of the main folder within the output structure. year_format (str) - The format for the year folder name. month_format (str) - The format for the month folder name. day_format (str) - The format for the day folder name.
The main function of the script. It reads configuration data from a JSON file, creates a temporary directory, splits and merges JSON data, and generates Markdown files.
None.
None.
The script also includes a global variable config to store configuration data loaded from a JSON file and a constant EMOJI_MAPPING that maps activity types to emojis.