Hi,
I’m trying to convert numbers in a column from a CSV file to integers. It seems those numbers are of unicode type. The problem is that I get an error when calling int()
on that number:
invalid literal for int() with base 10: ‘ink’
def setup():
size(1000, 600, P3D)
csv = loadTable("citrohanCSV.csv")
#0 - 1 - 2 - 3 - 4
#id - x - y - z - links
for ir in xrange(csv.getRowCount()):
for ic in xrange(csv.getRow(ir).getColumnCount()):
links = splitTokens(csv.getRow(ir).getString(4)[1:-1], ',')
print links # returns a number like 127, 3918 or 41
print type(links) # returns 'unicode'
print int(links) # returns the error
I googled the error but couldn’t find a similar issue.
Questions:
- How can I convert that unicode value to an integer ?
- If that’s not possible what workaround would you suggest ?
(link to the csv file if needed)