Search code examples
pythonblazeodo

How do you pass an encoding to odo when loading a csv file?


The odo documentation is quite sparse, it does not explain how to pass further parameters when, say loading a csv file. For example, how do I tell odo that the file is latin1 encoded?

data=[]
odo('mylatin1.csv',data)

Solution

  • Try using the encoding keyword argument:

    data = []
    odo('mylatin1.csv', data, encoding='latin1')
    

    Alternatively, try specifying the encoding using odo.resource:

    from odo import resource
    
    my_csv = resource('mylatin1.csv', encoding='latin1')
    data = []
    odo(my_csv, data)