mardi 4 août 2015

using pandas to read in a single column CSV

I am attempting to read in a single column CSV using the read_csv() function, but for some reason whenever I attempt to, i get an error:

ValueError: 'Message' is not in list

Here is the code that i am using (just a warning, I did not write all of this. I am inheriting this script from someone else and i have to maintain it.)

def get_data(fp, encoding='utf-8', columns=['Message']):
    """Get the columns from the raw data file provided."""
    if 'csv' in fp.split('.')[-1]:
        data = pd.read_csv(fp, usecols=columns,
                           converters={'Message':
                                       lambda x: unicode(x,
                                                     encoding,
                                                     errors='ignore')})

I am unsure why i am having this issue, and any help or pointing me in the right direction would be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire