-
-
Save nfway/72f8b1fb62232702f5335c05902100ee to your computer and use it in GitHub Desktop.
convert each row in csv to a markdown file in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
def toMarkdown(item): | |
newTemp = "---"+"\n"+"layout: sculpture"+"\n"+"pageId: "+item[0]+"\n"+"uid: "+item[1]+"\n" | |
newTemp += "title: "+item[2]+"\n"+"location: "+item[3]+"\n"+"completionDate: "+item[4]+"\n" | |
newTemp += "description: "+item[5]+"\n"+"imageId: "+item[6]+"\n" | |
newTemp += "---"+"\n" | |
return newTemp | |
with open('file.csv', 'rb') as f: | |
reader = csv.reader(f, delimiter='|', quoting=csv.QUOTE_NONE) | |
for row in reader: | |
with open('temp/o' + str(row[0]) + '.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