0

I'm trying to read one column from a csv (with header 'Peptide Sequence'). However, this gives me the error as in the title. I know this probably has something to do with the encoding, which I know very little about. Is there a quick workaround for this?

import pandas as pd
file = r'C:\...\thpdb.csv'
df = pd.read_csv(file, usecols=['Peptide Sequence'])
print(df)
2
  • 1
    try this: df = pd.read_csv(file, usecols=['Peptide Sequence'], encoding = "ISO-8859-1") Commented Jun 26, 2022 at 12:03
  • you're welcome! I posted the solution as an answer, if you could accept it that would be great! Good luck with the project. Commented Jun 26, 2022 at 12:29

1 Answer 1

2

read_csv takes an encoding argument to deal with files in different formats, "ISO-8859-1" should work for you. See here:

import pandas as pd
file = r'C:\...\thpdb.csv'
df = pd.read_csv(file, usecols=['Peptide Sequence'], encoding = "ISO-8859-1")
print(df)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.