Home > Blockchain >  Is there a way to insert a particular sequence in the header and the footer of a csv, shifting the d
Is there a way to insert a particular sequence in the header and the footer of a csv, shifting the d

Time:06-21

the result should be a csv having a sequence in the header and the footer

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)
  • Related