I need some help. I want to read from three different txt files. In firs file there is one line, on second and third files I want to read only the second line. I would like to output to the same line. I have tried to get rid of "spaces" in the end of the file with on_off.strip(), on_off.replace(" ","") but it is the same.
code:
f = open(pathToAbsoReport, "r")
serial = (f.read(15))
h = open(pathON_OFF, "r")
on_off = (h.readlines())
g = open(pathRepeat, "r")
repeat = (g.readlines())
if serial[0] == "6":
d = open(writePath, "a")
d.write(serial + "," + on_off[1] + "," + repeat[1] + "
")
d.close()
Output:
6V1920xxxxx0001,544,534,10,327,323,4,283,276,7,OK
,541,539,2,325,323,2,278,275,3,OK
I would like:
6V1920xxxxx0001,544,534,10,327,323,4,283,276,7,OK,541,539,2,325,323,2,278,275,3,OK
Thank you!
question from:
https://stackoverflow.com/questions/66059948/write-to-the-same-line-pyhton