Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 27th, 2013  |  syntax: Python  |  size: 0.56 KB  |  views: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # arguments: (in csv file: string) (out csv file: string) (ticker: string) (all or a/m/d: bool)
  2. import sys
  3. import string
  4.  
  5. ticker = sys.argv[3]
  6. allTypes = bool(sys.argv[4])
  7.  
  8. with open(sys.argv[1]) as ifile, open(sys.argv[2], mode = 'w') as ofile:
  9.         for row in ifile:
  10.                 if (row[6] == ticker):
  11.                         print row
  12.                         # add something to make sure chronological order hasn't been broken
  13.                         if (allTypes == 1):
  14.                                 ofile.write(row)
  15.                         else:
  16.                                 if (row[0] == "A" or row[0] == "M" or row[0] == "D"):
  17.                                         print row
  18.                                         ofile.write(row)
  19. ifile.close()
  20. ofile.close()