'Problem importing txt file data with pandas

df = pd.read_csv("AVG.txt")
df

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

I'm a beginner i'm trying to interpret some data with python and i ran into this error trying to load the file

This is the file I am trying to upload: File



Solution 1:[1]

This is probably an encoding issue, try

df = pd.read_csv("AVG.txt",encoding="utf-16")

You may also try using the basic open() function and parse it later on

Solution 2:[2]

The file is a .txt file. If you save it as a .csv should work fine (e.g. copy into Excel and use Save As). Just tried it and its worked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Grall
Solution 2 A Rob4