Csv2sc

Convert comma-separated value (CSV) files to SC format with #Python

#!/usr/bin/env python3
import sys,string

d=','
a="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
r=0
o=[":"]
for l in open(sys.argv[1]):
    c=0
    for p in l.rstrip().split(d):
        if not p:continue
        try:
            o+=["let %s%d = %d"%(a[c],r,int(p))]
        except:
            o+=["leftstring %s%d = %s"%(a[c],r,p if p[0]=='"' else '"%s"'%p)]
        c+=1
    r+=1
print("\n".join(o))

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply