Not able to load a pickle file. I am using python 3.5
import pickle
data=pickle.load(open("D:\\ud120-projects\\final_project\\final_project_dataset.pkl", "r"))
TypeError: a bytes-like object is required, not 'str'
. .
Also tried:
import pickle
data=pickle.load(open("D:\\ud120-projects\\final_project\\final_project_dataset.pkl", "rb"))
UnpicklingError: the STRING opcode argument must be quoted
. .
Same errors even when using with statements
import pickle
with open("D:\\ud120-projects\\final_project\\final_project_dataset.pkl", "rb") as f:
enron_data = pickle.load(f)


You definitely need the "rb" to read the file, which solves the first problem.
The second issue (STRING opcode argument) is because the file doesn't have Unix line endings. You need to run the pkl file through a script to convert them. If you see this thread, there is a script called "dos2unix" that will solve that for you:
How to convert DOS/Windows newline (CRLF) to Unix newline (\n) in a Bash script?