I m using the below python code to write data to a CSV file with column name.
def get_filename_datetime():
# Use current date to get a text file name.
return "Report-" + str(datetime.date.today())
# Get full path for writing.
filename = get_filename_datetime()
Data = [["FirstName", "LastName","Failed_User_Id"],
[firstname, lastname, faileduserid]]
Reportfilename = os.path.join(reportspath, filename)
myfile = open(Reportfilename + '-Results.csv', "a+")
with myfile:
writer = csv.writer(myfile)
writer.writerows(Data)
I'm getting output in a file as:
My expected output is:
I'm getting output in a file as:
But I'm getting column name printed for each and every row.