what’s wrong with this pandas and txt file code?

The problem here is that when you read the lines of your file in Python, it also gets the line break per row so that you have to strip it off.

Let’s suppose that the first line of your teste3.txt file is “James Brown”. It’d be read as “James Brown\n” and not recognized in the search.

Changing the last chunk of your code to:

with open("teste3.txt", "r") as f:
    for row in f:
        art = row.strip()
        buscarA()

should work.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top