I feel like this is a simple task, but being so new to python and not having the time to fully come to grips with it I am utterly overwhelmed...
I simply want to replace whatever text is at a particular position in a particular line with the value I have read from another file. For example (clearly wrong)
ifile = open('inputfile.txt','r') #Read inputfile.txt which contains multiple lines with 2 cols of data, the 1st col contains the name of a variable & the 2nd col a new value to use such that eg. line=('Variable1', 'new_value1'); line=('Variable2', 'new_value2') with open('ofile.txt', 'w') as outfile: with open(ifile, 'r') as infile: for line in infile: if line.startswith('Variable1'): outfile.write(#???write new_value1 to line x from position y to z of the line (incl blanks) ???) continue if line.startswith('Variable2'): outfile.write(#???somehow write new_value2 to line i from position j to k of the line (incl blanks) ???) continue