0

iam trying to save user input under the csvcolumns as shown below, but each input is being saved in its own row. Example: if you input John under the name variable, its being saved as j o h n below is the code.

import time
import csv
csvcolumns= [ "NAME", "CAR MAKE", "YEAR OF MANUFACTURE", "IDENTIFICATION     NUMBER", "DATE"]
Name= input("Enter your name: ")
Car_make= input("Enter your car make e.g Toyota probox: ")
YOM= input("Enter the car YOM: ")
ID= input("Enter your identification number details: ")
todays_date= time.strftime("%Y-%m-%d %H:%M:%S")
with open('E:\doo.csv', 'w') as csvFile:
  writer=csv.writer(csvFile, delimiter=',')
  writer.writerow(csvcolumns)
  writer.writerows(zip(Name, Car_make,YOM,ID,todays_date))


print("writing completed")
1
  • Seems to be a problem with python interpreting your String Name as an iterable sequence. Commented Oct 26, 2018 at 19:46

1 Answer 1

2

You're lost somewhere in complex things.

If all this data is single row, write it with

writer.writerow([Name, Car_make, YOM, ID, todays_date])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.