I am having a bit of trouble reading data from a CSV file as an integer.
Here is an example of my CSV file:
Col1 Col2 Col3
Header Header Header
Header 1 1,000,000
BLANK 2 500,000
BLANK 3 200,000
What I am wanting to do is read in the data from 'Col3' (not including the header) as integers into a tuple.
Here is my code:
import csv
prizePoints = []
with open("csvfile.csv") as prizes:
next(prizes)
for row in prizes:
prizePoints.append(row)
When I try this, I get an error that says:
ValueError: invalid literal for int() with base 10: '"1'
Example of printed row:
['', '1', '1,000,000']
I think it is due to the values in 'Col3' having commas. However, I am unsure of how to fix this so any help would be greatly appreciated!
P.S. I can't change the format of the values for 'Col3' so that they do not have commas.