#!/usr/bin/env python

import sys
import pdb

def returnCollapsedLine(line):
    fields = splitLine(line)
    for idx in range(11, len(fields)):
        if fields[idx] == '':
            fields[idx] = ''
        else:
            fields[idx] = '1'
    return ','.join(fields)

def splitLine(line):
    fields = line.strip().split(',"')
    for idx in xrange(0, len(fields)):
        fields[idx] = fields[idx].translate(None, '",')
    return fields

firstLine = True
with open(sys.argv[1], "rU") as fhi:
    with open(sys.argv[2],'w') as fho:
        for line in fhi:
            if firstLine:
                firstLine = False
                fho.write(','.join(splitLine(line)) + "\n");
            else:
                fho.write(returnCollapsedLine(line)+"\n")


@@ -15,17 +15,16 @@
  python%0A
-%0A
 import s
@@ -36,16 +36,402 @@
 port pdb
+%0Aimport argparse%0A%0Adef collect_args():%0A    parser = argparse.ArgumentParser(description = %22Minimise a ROARY csv file%22)%0A    parser.add_argument('-i', '--fileIn', type = str, required = True, help='Path to ROARY CSV file (required)')%0A    parser.add_argument('-o', '--fileOut', type = str, required = True, help='Output path (minimised ROARY CSV) (required)')%0A    return parser.parse_args()
 %0A%0Adef re
@@ -828,16 +828,58 @@
 fields%0A%0A
+def main():%0A    args = collect_args()%0A    
 firstLin
@@ -887,16 +887,20 @@
  = True%0A
+    
 with ope
@@ -905,19 +905,19 @@
 pen(
-sys.argv%5B1%5D
+args.fileIn
 , %22r
@@ -928,24 +928,28 @@
 as fhi:%0A    
+  
+  
 with open(sy
@@ -950,19 +950,20 @@
 pen(
-sys.argv%5B2%5D
+args.fileOut
 ,'w'
@@ -976,24 +976,28 @@
 ho:%0A        
+    
 for line in 
@@ -1009,24 +1009,28 @@
             
+    
 if firstLine
@@ -1043,24 +1043,28 @@
             
+ 
+   
 firstLine = 
@@ -1069,16 +1069,20 @@
 = False%0A
+    
         
@@ -1138,38 +1138,46 @@
 %22);%0A            
+  
+  
 else:%0A
+    
                 
@@ -1215,12 +1215,51 @@
 ine)
-+
+ + 
 %22%5Cn%22)%0A%0A
+if __name__== %22__main__%22:%0A    main()%0A

add usage args to minimise ROARY script