Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created function that generates singular block for markdown #18

Merged
merged 2 commits into from
Jul 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions generate-markdown.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
from sort import Sort

s = Sort()

element_list = s.sort("db.csv")
def generate_block(row): # generates a singular block for the markdown. row is a string parameter.
word_block = ""
element_list = row.split(",")
if element_list[1] == "":
word_block += "## " + element_list[0] + " = NULL\n\n"
else:
word_block += "## " + element_list[0] + " = " + element_list[1] + "\n\n"

with open("markdown.md", "w", encoding="utf-8") as f:
for i in range(0, len(element_list[0])):
if element_list[1][i] == "":
f.write("## " + element_list[0][i] + " = mr\n\n")
else:
f.write("## " + element_list[0][i] + " = " + element_list[1][i] + "\n\n")
f.write("|" + element_list[3][i] + "|\n")
f.write("|---|\n")
f.write("|" + element_list[4][i] + "|\n\n")
f.write("---\n")
if element_list[3] == "":
word_block += "|NULL|\n"
else:
word_block += "|" + element_list[3] + "|\n"
word_block += "|---|\n"
if element_list[4] == "":
word_block += "|NULL|\n\n"
else:
word_block += "|" + element_list[4] + "|\n\n"
word_block += "---\n"

return word_block


print(generate_block("experience,अनुभव,daily,I have experience in this.,मला यात अनुभव आहे."))