Using the File System Object in Event Scripts
You can use the Jython file system object to process files and folders. The following example uses the file system object to create a file and to copy the contents of an existing file to the new file.
Read the following Input FileEntity,Currency,ICP,Product,Store,Channel,Custom4,Custom5,Custom6,Custom7,UnitsSold,SalesEastSales, USD, [ICP None], H740, Comma_Phone_Stores, Retail_Direct, [None],[None],[None],[None],127,9954.103768EastSales, USD, [ICP None], H740, Freds, National_Accts, [None],[None],[None],[None],112,6610.371552EastSales, USD, [ICP None], H740, Good_Buy, National_Accts, [None],[None],[None],[None],112,6610.371552Write the following Output FileEastSales, USD, [ICP None], H740, Comma_Phone_Stores, Retail_Direct, [None],[None],[None],[None],UnitsSold,127EastSales, USD, [ICP None], H740, Comma_Phone_Stores, Retail_Direct, [None],[None],[None],[None],Sales,9954.103768EastSales, USD, [ICP None], H740, Freds, National_Accts, [None],[None],[None],[None],UnitsSold112EastSales, USD, [ICP None], H740, Freds, National_Accts, [None],[None],[None],[None],Sales6610.371552EastSales, USD, [ICP None], H740, Good_Buy, National_Accts, [None],[None],[None],[None],UnitsSold,112EastSales, USD, [ICP None], H740, Good_Buy, National_Accts, [None],[None],[None],[None],Sales,6610.371552infilename = fdmContext["INBOXDIR"]+"/InputFile.txt"outfilename = fdmContext["INBOXDIR"]+"/DataFile.txt"infile = open(infilename, "r")outfile = open(outfilename, "w")for line in infile:  column = line.rsplit(',',2)  if column[2].strip() != "Sales" :    outfile.write(column[0] + ",UnitsSold," + column[1] + "\n")    outfile.write(column[0] + ",Sales," + column[2])outfile.close()