-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_notes_from_quotes.py
61 lines (54 loc) · 1.32 KB
/
create_notes_from_quotes.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pandas as pd
from pathlib import Path
import numpy as np
from time import sleep
quotes = pd.read_csv(Path(__file__).parent / "Quotes.csv")
for index, row in quotes.iterrows():
print(row)
favorite = "true" if row["Favorite?"] == "Yes" else ""
tags = row["Tags"]
tags = " ".join(
""
if type(tags) != str
else [
f'[[{tag.replace("-", " ").strip().title()}]]'
for tag in tags.split(", ")
]
)
comments = (
"" if type(row["Comments"]) != str else "\n" + row["Comments"] + "\n"
)
file_data = f"""---
date: {row["Created"]}
time: {row["Time"]}
aliases:
favorite: {favorite}
---
@tags: #perm📝/quote💬
@links: {tags}
@attributed-to: [[{"" if type(row["Author"]) != str else row["Author"]}]]
> [!QUOTE]
> {row["Quote"]}
{comments}
---
## Related
-
## References
- """
# print(file_data)'
file_name = (
str(row["Quote"])
.replace("“", "")
.replace("”", "")
.replace("\n", " ")
.replace('"', "")
.replace("?", ".")[:252]
+ r".md"
)
file_path = Path(
r"C:/Users/Quinn/Documents/Code Repositories/obsidian-bulk-editing-utils/generated_quotes/"
+ file_name
)
with open(file_path, "w", encoding="utf8") as f:
f.write(file_data)
sleep(2)