-3

My code looks like this.

    import csv
    name = input("entername")
    with open('details.csv','a') as csvDataFile:
        csvWriter = csv.writer(csvDataFile)
        csvWriter.writerow(name)

When i run it, and say my name was name, the csv file would look like this:

n a m e

with each of the letters being in seperate cells, how do i get them into one, without using a list.

Novicus
  • 1
  • 1
  • Possible duplicate of [Python : csv.writer writing each character of word in separate column/cell](https://stackoverflow.com/questions/15129567/python-csv-writer-writing-each-character-of-word-in-separate-column-cell) – glibdud Nov 14 '17 at 13:36
  • 3
    Possible duplicate of [Why does csvwriter.writerow() put a comma after each character?](https://stackoverflow.com/questions/1816880/why-does-csvwriter-writerow-put-a-comma-after-each-character) – zipa Nov 14 '17 at 13:36

1 Answers1

0

Try,

csvWriter.writerow([name])

writerow() is expecting an iterable of strings, https://docs.python.org/2/library/csv.html#csv.csvwriter.writerow

if you give "hello", it will write h, e, l, l, o

if you give ["hello", "world"], it will write as hello, world

Jomin
  • 113
  • 2
  • 8