I have tried writing the header and footer sequences with python excelwriter and then converting it to csv but it does not work. Can anyone suggest me a piece of code in python ?
CodePudding user response:
Open your output file and simply write to it. Let pandas to_csv write to the open file object.
with open("myoutput.csv", "w") as file:
# output your first line
print("1890000123", file=file)
# continue to add the csv
df.to_csv(file, ... other options here)
print("178AD...", file=file)