mjrezayani Wrote:But, I want to have changes(modifications) on my original file not a new one.I have used in-place some times,It's easy to use
When using csv module most rewriter a little so it write like writerow(csv module).
Quick test.
# -*- coding: utf-8 -*- """ Created on Wed Jun 2 21:02:44 2021 @author: LENOVO """ import csv from in_place import InPlace with InPlace('csv_data.csv', encoding='utf-8', backup='otherfile.csv') as revised_file: reader = csv.reader(revised_file, delimiter=';') writer = csv.writer(revised_file, delimiter=';', quoting=0) for idx, row in enumerate(reader, start=1): if idx >= 3: row.insert(1, row[1][0]) row[2] = row[2][1:] revised_file.write(f"{';'.join(row)}\n")This line it's not needed anymore as it was in Python 2💀
# -*- coding: utf-8 -*-