I try to tokenize the text file that i get from my zip folder but i am facing this error
My Error
TypeError: expected string or bytes-like object
I try to tokenize the text file that i get from my zip folder but i am facing this error
My Error
TypeError: expected string or bytes-like object
Add r
to yourC:\Users\killer\Desktop\User1.txt
so the backslash become \\
instead of \
because \U
in Users
is being interpreted as a start of an unicode
pd.read_csv(r"C:\Users\killer\Desktop\User1.txt")
Or you can escape it manually or just change \
to /
What you are doing is right but there are some characters that can't be read (not Unicode characters). This is because the file path you have given as \U
(from \User
) will by default be recognized as an escape sequence character and is unknown. For a file path to be recognized as one, you have to:
A) write it with \\
, for eg. "C:\\Users\\killer\\..."
B) write it with /
, for eg "C:/Users/killer/..."
C) use r
in front, for eg. r"C:\Users\killer\"
to use it as raw text, ie, everything is text and no escape sequences, etc.
Try the following code:
Data = pd.read_csv("C:\Users\killer\Desktop\User1.txt", sep=", ")
Just add => , sep=", "
at the end of the file you want to read.
Note that in quotation marks add what separates the text. In most cases, the text is separated by a comma "," but you can check the file by opening it with your default text reader to see what separates it.