Skip to content

Instantly share code, notes, and snippets.

@vmx
Created March 16, 2020 22:14
Show Gist options
  • Save vmx/ec00d7fce28f476df62644fac8926d40 to your computer and use it in GitHub Desktop.
Save vmx/ec00d7fce28f476df62644fac8926d40 to your computer and use it in GitHub Desktop.
Script to convert a CSV file with Markdown to a CSV file with HTML
#!/usr/bin/env python3
import csv
import os
import cmarkgfm
FIELDNAMES = ['id', 'title', 'description']
with open('talks.csv', newline='') as inputfile:
reviews = csv.DictReader(inputfile, delimiter=',', quotechar='"')
output_path = os.path.join('2020_foss4ge', 'talks_html.csv')
with open(output_path, 'w', newline='') as outputfile:
writer = csv.DictWriter(outputfile, FIELDNAMES, delimiter=',',
quotechar='"')
writer.writeheader()
for row in reviews:
description = cmarkgfm\
.github_flavored_markdown_to_html(row['description'])
# print(description)
row['description'] = description
writer.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment