I want to replace a column in a text file based on values from another text file. I skipped first 3 header lines and read second column from file1 into a list L and want to replace column 2 in file2. Following is what I have:
L = []
for index, line in enumerate(open("C:/file1.txt", "r")):
if index <= 2:
continue
else:
L.append(line.split()[1])
For example:
L = ['2.3','1.2']
and text file is:
x y z
1.1 2.1 1.4
1.9 1.8 2.1
I want to replace values under variable y with list L values. Any suggestions would be appreciative.
pandaspackage it might save you lot of time and efforts