Created
September 28, 2011 14:12
-
-
Save qoda/1248036 to your computer and use it in GitHub Desktop.
Small program to fix csv format to work in Apple Numbers.
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
#!/usr/bin/env python | |
import csv | |
import sys | |
def convert_csv(file_path): | |
file_name = file_path.replace(".csv", "") | |
csv_reader = csv.reader(open("%s.csv" % file_name, "r")) | |
csv_writer = csv.writer(open("%s.fixed.csv" % file_name, "w"), quoting=csv.QUOTE_ALL, delimiter=';') | |
for line in csv_reader: | |
csv_writer.writerow(line) | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
exit("Usage: python convert_csv.py /path/to/file.csv") | |
file_path = sys.argv[-1] | |
convert_csv(file_path) | |
print "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment