JSON will look like this:
{
"date": "2024-05-22T16:16:58.6891617",
"heading": "Diary Entry",
"html": "<p>Today was a good day</p>",
"location": [
51.033474581705315,
8.7675160241127014
],
"tags": [
"party",
"work"
],
"people": [
"Name1",
"Name2"
],
"tracker": [],
"weather": "21 / 13 °C"
}
Converting to CSV is also easy. If I want to convert for example April 2024 to CSV I use following code:
import json
import pandas as pd
# Load the JSON data
file_path = '/data/Diarium_2022-08-01_2024-05-22.json'
with open(file_path, 'r') as file:
data = json.load(file)
# Filter entries for April 2024
april_2024_entries = [entry for entry in data if '2024-04' in entry['date']]
# Convert to DataFrame
df_april_2024 = pd.DataFrame(april_2024_entries)
# Save to CSV
csv_file_path = '/data/April_2024_entries.csv'
df_april_2024.to_csv(csv_file_path, index=False)
csv_file_path
Hope this helps!