Skip to content

Instantly share code, notes, and snippets.

@JoJoDeveloping
Created May 9, 2019 21:52
Show Gist options
  • Save JoJoDeveloping/15fef58771bbebdc5ed26bfdeeffc35b to your computer and use it in GitHub Desktop.
Save JoJoDeveloping/15fef58771bbebdc5ed26bfdeeffc35b to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import sys
#Note that this is executed by moving all old md files into a folder like old and then running ./migrator.py $(cd old; ls *.md), because I was to lazy to implement proper file path handling
for f in sys.argv:
ns = f.split("-")
if f[-3:] != ".md": continue
if len(ns) != 3: continue
fv = ns[0]
tv = ns[2][:-3]
file = open("old/"+f, "r")
entries = []
there=False
ate=False
copy = open(f,"w")
for line in file:
if ate:
copy.write(line)
continue
lp = line.split("|")
if not there:
copy.write(line)
if len(lp) != 4: continue
if lp[1][0] != '-': continue
there = True
continue
if len(lp) != 4 or lp[1][0]== '=':
ate = True
copy.write(line)
continue
fcn = lp[1].strip()
tcn = lp[2].strip()
entries = entries + [fcn + "," + tcn]
file.close()
file = open(fv + "-to-" + tv + ".csv", "w")
for e in entries:
file.write(e+"\n")
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment