I have a python program that converts csv files to '^' delimiter files. The output files also has new headers.
cc = input("Enter Code \t")
cn = input("Enter Item Number \t")
input_file = input("Enter input file \t")
act = input("Enter Action (Update- N/Delete -Y) \t")
def file_conversion(input_file, output_file_pattern, chunksize):
with open(input_file,"r+") as fin:
# ignore headers of input files
for i in range(1):
fin.__next__()
reader = csv.reader(fin, delimiter=',')
for i, chunk in enumerate(chunked(reader, chunksize)):
with open(output_file_pattern.format(i), 'w', newline='') as fout:
writer = csv.writer(fout,reader,delimiter='^')
writer.writerow(headers)
writer.writerows(chunk)
print("Successfully converted into", output_file_pattern)
The program works now I want to add act,cc and cn in every line of output delimiter files. The lines of output files should start like the line below
act^cc^cn^restofcsvdelimitierfiles.