Closed. This question does not meet
CodePudding user response:
Why not leverage pandas for this task?
import pandas as pd
df = pd.read_csv('abc.csv')
df.to_csv('abc_piped.csv', sep='|')
CodePudding user response:
Although I agree that Pandas is a hugely useful package, I will go with what you have (with my changes):
from csv import reader, writer, QUOTE_MINIMAL
with open(filein, encoding='utf-8') as in_fd,
open('Detail_Test_Piped.csv', 'wt', encoding='utf-8') as out_fd:
csv_read = reader(in_fd)
csv_write = writer(out_fd, delimiter='|', quotechar='"', quoting=QUOTE_MINIMAL)
csv_write.writerows(csv_read)
I don't know if it counts as an "advantage", but this works "out of the box" without having to install third-party packages.