All pastes #1770194 Raw Edit

Stuff

public python v1 · immutable
#1770194 ·published 2010-01-29 02:13 UTC
rendered paste body
import sysimport fileinputimport csvfrom csv_col_reader import *def main():    # Get file contents    s1_finName = "../012710-WHSE5.csv"    s1_foutName= "../012710-WHSE5-step1.csv"    #Use the regular reader to prep the raw file for use in the better csv_col_reader    fin = open(s1_finName,"r")    contents = fin.readlines()    fin.close()    # cleanup header    del contents[0:3+1]    del contents[1]    contents_0_save = contents[0]    contents_0 = contents_0_save.rsplit(",")    del contents_0[5]    fixed_header = ['"Bin Cmt"','"Bin Avl"','"U/M"']    contents_0.insert(5,fixed_header[0])    contents_0.insert(6,fixed_header[1])    contents_0.insert(7,fixed_header[2])    del contents[0]    contents.insert(0,map(str, contents_0))      #  contents_0[5] = fixed_header    print "contents[0] pre   == ",contents[0]    print "contents_0_save   == ",contents_0_save    print "contents_0        == ",contents_0    print "contents[0] final == ",contents[0]    # Get rid of empty lines    contents = filter(lambda contents: len(contents)>0, contents)    for xx in range(3):        print xx, contents[xx]    fout = open(s1_foutName,"w")    fout.writelines(contents)    fout.close()    s2_finName = s1_foutName    s2_foutName= "../012710-WHSE5-step2.csv"    reader = ReaderCol()   # reader.read_filename(s2_finName,"windows-1252")    # Copy down bin numbers    print "============================"    print "Copy Down Bin Numbers Output"    print "============================"    new_contents=[]    for xx in range(len(contents)):                this_bin = contents[xx].split()        next_bin = contents[xx+1].split()        print xx,this_bin,next_bin,contents[xx]        if xx == 10:            break    # Get some useful dbg output    print "============"    print "Final Output"    print "============"    ctr = 0    for line in contents:        ctr += 1        if ctr == 10:            break   #     print line    # Print file sans processing    #print "".join(contents[0:9])if __name__ == "__main__":    main()