Skip to content

Instantly share code, notes, and snippets.

@qoda
Created September 28, 2011 14:12
Show Gist options
  • Save qoda/1248036 to your computer and use it in GitHub Desktop.
Save qoda/1248036 to your computer and use it in GitHub Desktop.
Small program to fix csv format to work in Apple Numbers.
#!/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