# arguments: (in csv file: string) (out csv file: string) (ticker: string) (all or a/m/d: bool)
import sys
import string
ticker = sys.argv[3]
allTypes = bool(sys.argv[4])
with open(sys.argv[1]) as ifile, open(sys.argv[2], mode = 'w') as ofile:
for row in ifile:
if (row[6] == ticker):
print row
# add something to make sure chronological order hasn't been broken
if (allTypes == 1):
ofile.write(row)
else:
if (row[0] == "A" or row[0] == "M" or row[0] == "D"):
print row
ofile.write(row)
ifile.close()
ofile.close()