Dec-06-2020, 08:56 AM
(This post was last modified: Dec-06-2020, 08:56 AM by Python_User.)
What does this part of the code below? Could you provide some explanation behind the lines of code as comments?
def read_csv_file(filename): parts = list(filename.parts) parts[-1] = f"{filename.stem}_Modified{filename.suffix}" parts[0] = '' outfilename = Path(f"{'/'.join(parts)}") print(f"new output file name: {outfilename}") with filename.open() as fp, outfilename.open('w') as fout: crdr = csv.reader(fp, delimiter=',') cwrtr = csv.writer(fout, delimiter=',') for row in crdr: print(row) # Modify row as desired here cwrtr.writerow(row)