Skip to content

Instantly share code, notes, and snippets.

@sw82
Forked from cherihung/csv-to-mkdown-files.py
Last active May 17, 2021 20:25
Show Gist options
  • Select an option

  • Save sw82/142bfb8e3b338ce2eff3ceb0e2d3bed1 to your computer and use it in GitHub Desktop.

Select an option

Save sw82/142bfb8e3b338ce2eff3ceb0e2d3bed1 to your computer and use it in GitHub Desktop.
convert each row in csv to a markdown file in python
import csv
# Name,Contact made by,Rating,Service Area,Last Catchup,Notes
def toMarkdown(item):
#print(item)
newTemp = "# About"+"\n"+"\n"
newTemp += "- Intro via [["+f"{item['Contact made by']}"+"]]"+"\n"+"\n"
newTemp += "- #Rating"+f"{item['Rating']}"+"\n"+"\n"
newTemp += "# Tags"+"\n"+"- #" +f"{item['Service Area']}"+"\n"+"\n"
#newTemp += "# Notes"+"\n" +"- " +f"{item['Notes']}" +"\n"
return newTemp
with open('test.csv') as f:
reader = csv.DictReader(f)
for row in reader:
#print(f"{row['Name']}")
with open(f"{row['Name']}" + '.md', 'w') as output:
output.write(toMarkdown(row))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment