I have an input file:
A03 58 0 0 0 -9
A03 59 0 0 0 -9
A03 60 0 0 0 -9
A03 61 0 0 0 -9
A03 62 0 0 0 -9
A03 63 0 0 0 -9
A03 64 0 0 0 -9
A03 65 0 0 0 -9
A03 66 0 0 0 -9
A03 67 0 0 0 -9
A03 68 0 0 0 -9
A03 69 0 0 0 -9
A03 70 0 0 0 -9
A03 71 0 0 0 -9
A03 72 0 0 0 -9
A03 73 0 0 0 -9
A03 74 0 0 0 -9
My wanted output:
A03_58 A03_58 0 0 0 -9
A03_59 A03_59 0 0 0 -9
A03_60 A03_60 0 0 0 -9
The output will consider the second column in inputfile, add underscore to the first column and that letter. Then take that and copy it to the second column. I do know how to copy a column wit this:
# with open('inputfile.txt') as inputs:
# for line in inputs:
# parts = line.strip().split()
# print("{0} {1}".format(parts[0], " ".join(parts)))
However, I need to change the column first and delete the second column before using above script.
I am not sure how to approach this after reading in the large input file. Browsed through some indexing questions, but can't find an answer.
Aucun commentaire:
Enregistrer un commentaire