Im an entry level Python developer working on a requirement where I need to merge so many text files in forder A into one file in Folder B. I wrote the below code which is working but its not writing the entire content from files in folder A.
import os
a = open(r"C:\temp\datsOutput\New folder\output.txt", "w")
path = r'C:\temp\dats'
for filename in os.listdir(path):
fullPath = path+"\\"+filename
with open(fullPath,'r',encoding="utf_8_sig", errors="ignore") as ins:
for line in ins:
a.write(line)
the around 6000 lines from the below line are missing.
ROUT:= 996.6mm
ANGL:= 95degree
ORRF:= =0/0
TMRREF:= =0/0
REPCOU:= 0
END
NEW CYLINDER 26 of SUBEQUIPMENT /FA-3101/MAIN_M1_DAVIT
NAME:= =805324448/24319
TYPE:= CYLI
LOCK:= false
OWNER:= /FA-3101/MAIN_M1_DAVIT
PURP:= unset
POS:= W 537.345mm S 46.083mm U 0mm
ORI:= Y is S and Z is U
LEVE:= 0 10
OBST:= 2
DIAM:= 76.2mm
HEIG:= 304.8mm
ORRF:= =0/0
TMRREF:= =0/0
REPCOU:= 0
:PSTATUS:= unset
END
NEW CYLINDER 27 of SUBEQUIPMENT /FA-3101/MAIN_M1_DAVIT
NAME:= =805324448/24320
TYPE:= CYLI
LOCK:= false
OWNER:= /FA-3101/MAIN_M1_DAVIT
PURP:= unset
POS:= W 537.345mm S 46.083mm U 6.125mm
ORI:= Y is S and Z is U
LEVE:= 0 10
OBST:= 2
for testing purpose the folder A now has only one file which has 204034 lines and the script has written 203799 lines, is it a problem of encoding? I simply cant go any direction from here any small help is greatly appreciated and saves my job, thank you