Currently working on an EDI translation for a proprietary file format. The input file may have hundreds to thousands of records. Each line is a record.
INFILE:(Ignore beginning blank line, it's only there for visual representation)
"1","2","3","4","5","6","7","can also contain text, and commas","9","10","11","12","13"
"1","2","3","4","5","6","7","can also contain text, and commas","9","10","11","12","13"
"1","2","3","4","5","6","7","can also contain text, and commas","9","10","11","12","13"
"1","2","3","4","5","6","7","can also contain text, and commas","9","10","11","12","13"
"1","2","3","4","5","6","7","can also contain text, and commas","9","10","11","12","13"
I need a loop that can go line by line and copy data from one column in the original file, and paste it into a new file that holds the data in a different column. kind of like a vlookup without column headers. here is the relationship between column numbers.
InColumn-OutColumn
1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 12-9, 14-10, 25-11, 68-24
Thanks in advance, I can't seem to wrap my mind around this one.
EDIT: as requested here is the broken code that i couldn't get to work.
KEY = [1,2,3,4,5,6,7,8,12,14,25,68]
Body850 = open(TEMP, 'r+')
for line in Body850:
for x in line.split(','):
END += KEY[x]
print line