Sep-23-2017, 07:00 AM
(This post was last modified: Sep-23-2017, 07:00 AM by Pedroski55.)
I am using Python 3.5.2 and its csv module. I want to write to a csv file. To begin with, I just create a list:
Edit: Also, if I use words, I still get each letter in a separate column:
# open a file outputFile = open(pathToFile + 'outputFile.csv', 'w') outputFileWriter = csv.writer(outputFile) # create a list just to test the writer cellContent = [] for h in range(0, maxRow): cell = str(h) cellContent = cellContent + [cell]then, I want to write the list to a csv file:
# write the list to the rows just to test for h in range(1, maxRow): outputFileWriter.writerow(cellContent[h])This works. The numbers are written to the rows, but when the number has 2 digits, each digit appears in a separate column. I need all the numbers in column 1.
Edit: Also, if I use words, I still get each letter in a separate column:
cellContent = ['Peter', 'Paul', 'Mary', 'Jane'] for cell in cellContent: outputFileWriter.writerow(cell) 11 9 9 9 outputFile.close()Any tips or ideas?