-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconvert.py
34 lines (28 loc) · 1.16 KB
/
convert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
from os import listdir
from os.path import isfile, join
from os import getcwd
# Path to Google Keep Json files (to export Google Keep notes as Json, see: https://takeout.google.com/)
folder_path = "C:/.../"
# Find filenames with Json extension
json_files_in_folder = [f for f in listdir(folder_path) if isfile(join(folder_path, f)) and ".json" in f]
# Initialize empty dict according to SimpleNotes import format
aggregate_dic = {
"activeNotes": [],
"trashedNotes": []
}
# Get content from all Google Keep Json files
for filename in json_files_in_folder:
with open(join(folder_path, filename), encoding="utf-8") as f:
dic = json.loads(f.read())
if not dic['isArchived']:
aggregate_dic["activeNotes"].append(
{
"content": dic["title"] + "\r\n\r\n" + dic["textContent"],
"tags": [label["name"] for label in dic.get("labels") or []]
}
)
# Write all content into SimpleNotes Json import file
with open(join(getcwd(), 'notes.json'), 'w') as f:
f.write(json.dumps(aggregate_dic))
# To import, in SimpleNotes desktop app, open -> file -> import