0

I am trying to load a .dat file (RML2016_10b.dat) radio dataset from DeepSig using _pickle in Python 3.6 as follows:

from _pickle import load, dump
Xd = load(open("RML2016_10b.dat", 'rb'))

But I keep getting the following error:

Traceback (most recent call last):
  File "C:/Users/anoir/PycharmProjects/AMC/classification.py", line 14, in <module>
    Xd = load(open("RML2016_10b.dat", 'rb'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xde in position 0: ordinal not in range(128)

Can anyone give me a solution?

martineau
  • 119,623
  • 25
  • 170
  • 301
A.SDR
  • 177
  • 2
  • 11
  • 1
    Might be the case that the file was created with python2. Try this answer: https://stackoverflow.com/questions/28218466/unpickling-a-python-2-object-with-python-3 – H4kor Mar 17 '19 at 17:38
  • yes but i cannot use python 2 because i have to use tensorflow which does not work with python 2 – A.SDR Mar 17 '19 at 17:41
  • 1
    Read the answer: d = pickle.load(f, encoding='latin1') – H4kor Mar 17 '19 at 17:42
  • yes i am trying it now ... i just wanted to explain – A.SDR Mar 17 '19 at 17:44

1 Answers1

0

Thanks to H4Kor the from _pickle import load, dump

from _pickle import load, dump
Xd = load(open("RML2016_10b.dat", 'rb'), encoding='latin1')
A.SDR
  • 177
  • 2
  • 11
  • You don't need to explicitly `import _pickle` in Python 3. See [What difference between pickle and _pickle in python 3?](https://stackoverflow.com/questions/19191859/what-difference-between-pickle-and-pickle-in-python-3) – martineau Mar 17 '19 at 17:54