I'm trying to learn python to implement a user agent transformation script in our analytics database. I imported the user_agents lib to do the conversion and show me the user data. When executing this script in python reading a csv file that I extracted containing the user_agents (the csv has only one column) it returns this error:
TypeError: nailshable type: 'list'
Here is the script I am using:
import csv
from user_agents import parse
with open ('UserAgent.csv', 'r') as csv_file:
csv_reader = csv.reader (csv_file)
for line in csv_reader:
print (parse (line))
The parse
method takes a string as an argument. However, in your code, each line
is a list and not a string, you can try this:
with open('UserAgent.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
for line in csv_reader:
print( parse(' '.join(line)) )