def main(argv=None):
    if not argv:
        argv = sys.argv
    if len(sys.argv) == 3:
        CSV = sys.argv[1]
        if not CSV:
            print "Please supply a path to a csv file to process"
            exit()
        OUTDIR = sys.argv[2]
        if not OUTDIR:
            print "Please supply a path to an output directory"
            exit()
    else:
        print "Usage: python", sys.argv[0], "<csv_input> <output_dir>"
        print "First argument must be a path to a csv file to process"
        print "Second argument must be a path to a directory where the output files can be written (UNIX-style, ending in /)"
        exit()

    # load the csv
    print "Loading csv from " + CSV + " ..."
    c = CSVWrapper(CSV)
    print "done"
    print

    for col in interesting_cols.keys():
        print 'Saving interesting data wrt column', col, 'to', OUTDIR + filenames[
            col]
        print 'Slicing off these columns:', ', '.join(interesting_cols[col])

        filtered_rows = c.filter_rows(col, should_be_empty=False)

        c.save(OUTDIR + filenames[col], interesting_cols[col], filtered_rows)

        print '... done'
        print

    for col, csv in filenames.items():
        tmp = CSVWrapper(OUTDIR + csv)
        print 'Number of items in', csv, '=', len(tmp.csv_dict['id']), '.'
def main(argv=None):
    if not argv:
        argv = sys.argv
    if len(sys.argv) == 3:
        CSV = sys.argv[1]
        if not CSV:
            print "Please supply a path to a csv file to process"
            exit()
        OUTDIR = sys.argv[2]
        if not OUTDIR:
            print "Please supply a path to an output directory"
            exit()
    else:
        print "Usage: python", sys.argv[0], "<csv_input> <output_dir>"
        print "First argument must be a path to a csv file to process"
        print "Second argument must be a path to a directory where the output files can be written (UNIX-style, ending in /)"
        exit()
        
    # load the csv
    print "Loading csv from " + CSV + " ..."
    c = CSVWrapper(CSV)
    print "done"
    print

    for col in interesting_cols.keys():
        print 'Saving interesting data wrt column', col, 'to', OUTDIR + filenames[col] 
        print 'Slicing off these columns:', ', '.join(interesting_cols[col])
        
        filtered_rows = c.filter_rows(col, should_be_empty=False)
        
        c.save(OUTDIR + filenames[col], interesting_cols[col], filtered_rows)
        
        print '... done'
        print

    for col, csv in filenames.items():
        tmp = CSVWrapper(OUTDIR + csv)
        print 'Number of items in', csv, '=', len(tmp.csv_dict['id']), '.'
Example #3
0
print "done"
print

if MAKE_RELEASE and not RULE:
    runrules = release_only_rules

# run through all the rules, passing in the wrapper each time
count_run = 0
for rule in runrules:

    # skip certain rules based on whether we're making a draft or release version
    if MAKE_RELEASE:
        if rule in draft_only_rules:
            continue
    else: # we're doing a draft
        if rule in release_only_rules:
            continue
    
    print "Executing rule " + rule.__name__ + " ...",
    rule(csv_wrapper)
    count_run += 1
    print "done."
print

print 'Ran', count_run, 'rules'
print

# once we're finished, write out the results
print "Saving to " + OUT + " ..."
csv_wrapper.save(OUT)
print "done"