Skip to content

Instantly share code, notes, and snippets.

@sandaru1
Created March 8, 2010 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandaru1/325195 to your computer and use it in GitHub Desktop.
Save sandaru1/325195 to your computer and use it in GitHub Desktop.
import csv
f = open('trends.csv')
writer = csv.writer(open("fixed.csv", "wb"))
def valid(x): return (x!="," and x!="" and x!="\r\n");
def remove_new(x): return x.replace("\r\n","")
lines = ""
for line in f:
lines += line
a = lines.split('"')
a = filter(valid,a)
a = map(remove_new,a)
for i in range(0,len(a),12):
writer.writerow(a[i:i+12])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment