Python Forum
Why are these numbers broken into their digits?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why are these numbers broken into their digits?
#1
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:

 # 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?
Reply


Messages In This Thread
Why are these numbers broken into their digits? - by Pedroski55 - Sep-23-2017, 07:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is copying and pasting a block now broken? WagmoreBarkless 2 1,441 May-05-2022, 05:01 AM
Last Post: WagmoreBarkless
  Why is copying and pasting a block now broken? WagmoreBarkless 1 1,264 May-04-2022, 11:40 PM
Last Post: Larz60+
  BrokenPipeError: [Errno 32] Broken pipe throwaway34 6 9,507 May-06-2021, 05:39 AM
Last Post: throwaway34
  Single digits seem to be greater than double digits Frosty_GM 4 3,564 Nov-20-2020, 10:13 AM
Last Post: DeaD_EyE
  Python broken if moved to a different folder ecastrotns 3 2,497 Oct-26-2020, 10:53 PM
Last Post: ecastrotns
  STT: recognition connection failed: [Errno 32] Broken pipe GrahamBerends 0 5,119 Jul-18-2020, 11:00 PM
Last Post: GrahamBerends
  Python DateTime is broken 10OctNotOct10a1 8 4,842 Jan-03-2020, 07:54 AM
Last Post: snippsat
  Broken interpreter? fcktheworld587 1 2,302 Dec-26-2019, 08:29 PM
Last Post: snippsat
  I need a query to select the numbers that include 2 digits of 3 omidvakili 1 1,663 Sep-20-2019, 03:49 PM
Last Post: Yoriz
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,777 May-09-2019, 12:19 PM
Last Post: Pleiades

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020