Skip to content

Instantly share code, notes, and snippets.

@whatvn
Created March 2, 2012 03:10
Show Gist options
  • Save whatvn/1955267 to your computer and use it in GitHub Desktop.
Save whatvn/1955267 to your computer and use it in GitHub Desktop.
ZS Parser
#!/usr/bin/env python
# hungnv
import csv
L0 = [ x[0] for x in csv.reader(open('ZS_SOURCE.csv','r')) ]
L1 = [ x[1] for x in csv.reader(open('ZS_SOURCE.csv','r')) ]
L2 = [ x[2] for x in csv.reader(open('ZS_SOURCE.csv','r')) ]
L3 = [ x[3] for x in csv.reader(open('ZS_SOURCE.csv','r')) ]
#FL = []
for i in xrange(len(L1)):
if ( '/' in L2[i] ) and ('/' not in L3[i]):
for j in range(len(L2[i].split('/'))):
print L0[i] + ',' + L1[i] + ','+ L2[i].split('/')[j] +','+ L3[i]
elif ( '/' not in L2[i] ) and ('/' in L3[i]):
for j in range(len(L3[i].split('/'))):
print L0[i] + ',' + L1[i] +','+ L2[i] +','+ L3[i].split('/')[j]
elif ( '/' in L2[i] ) and ('/' in L3[i]):
for j in range(len(L2[i].split('/'))):
print L0[i] + ',' + L1[i] + ','+ L2[i].split('/')[j] +','+ L3[i].split('/')[j]
else: print L0[i] + ',' + L1[i] +','+ L2[i] +','+ L3[i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment