Skip to content

Instantly share code, notes, and snippets.

@kevin3
Created March 18, 2013 19:49
Show Gist options
  • Save kevin3/5190248 to your computer and use it in GitHub Desktop.
Save kevin3/5190248 to your computer and use it in GitHub Desktop.
Simple python script to join every 4 lines and also misc formatting to get SCB transactions auto formatted as a csv file
#!/usr/bin/python
"""simple python script to join every 4 lines into one from a plain text file"""
data = open("SCBtransactions2013-03-19.orig.csv").readlines()
data = [ i.strip() for i in data ] #get rid of newlines
data = [ i.replace("\t \t","\t") for i in data ] #get rid of double tabs
data = [ i.replace("SGD","") for i in data ] #get rid of SGD
fourlines = range(0,len(data),4)
for num,line in enumerate(data):
if num in fourlines:
print ' '.join(data[num:num+4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment