Context
I'm retrieving data from Google Analytics (via the python-googleanalytics library, as Google's API is way too complex for me right now) and putting that data into a table using an HTML library.
Python experience: very low.
Problem
I have this:
[integer]
[integer]
[integer]
[integer]
[integer]
The strings end up in a table column together and the integers in a table column. That's what I want. However, I don't want it to show any of the punctuation marks or the unicode u, just the bare strings and integers, but still in separate table columns.
What I'm trying to do is iterate over the list and the lists within the list to take all the values and encode them as ascii, but this cannot be done on integers. Maybe I should iterate over the strings and integer lists separately, but how should I separate them?
clean = []
for rows in top10:
for x in rows:
for i in x:
i = i.encode('ascii','ignore')
i = str(i)
clean.append(i)
Gives:
Traceback (most recent call last):
File "C:\Python26\googlescrape.py", line 31, in <module>
i = i.encode('ascii','ignore')
AttributeError: 'int' object has no attribute 'encode'
I would be grateful if someone could help me get to the next step.