'ValueError: 2 is not a valid PublicationSource

I am trying to read a pickle file and i am getting an error "2 is not a valid PublicationSource". I tried to read the file using different methods as mentioned below.

df=pd.read_pickle(r"C:\Users\sai\Dropbox\PC\Documents\googlescholar\temp6.pkl")
objects = []
with (open(r"C:\Users\sai\Dropbox\PC\Documents\googlescholar\temp6.pkl", "rb")) as openfile:
    while True:
        try:
            objects.append(pickle.load(openfile))
        except EOFError:
            break

I am getting the error as follows.

ValueError                                Traceback (most recent call last)
ValueError: 2 is not a valid PublicationSource
During handling of the above exception, another exception occurred:
ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_5888/55927084.py in <module>
      3     while True:
      4         try:
----> 5             objects.append(pickle.load(openfile))
      6         except EOFError:
      7             break
C:\ProgramData\Anaconda3\envs\myvenvpickle\lib\enum.py in __call__(cls, value, names, module, qualname, type, start)
    313         """
    314         if names is None:  # simple value lookup
--> 315             return cls.__new__(cls, value)
    316         # otherwise, functional API: we're creating a new Enum type
    317         return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
C:\ProgramData\Anaconda3\envs\myvenvpickle\lib\enum.py in __new__(cls, value)
    567                         )
    568             exc.__context__ = ve_exc
--> 569             raise exc
    570 
    571     def _generate_next_value_(name, start, count, last_values):
C:\ProgramData\Anaconda3\envs\myvenvpickle\lib\enum.py in __new__(cls, value)
    551         try:
    552             exc = None
--> 553             result = cls._missing_(value)
    554         except Exception as e:
    555             exc = e
C:\ProgramData\Anaconda3\envs\myvenvpickle\lib\enum.py in _missing_(cls, value)
    580     @classmethod
    581     def _missing_(cls, value):
--> 582         raise ValueError("%r is not a valid %s" % (value, cls.__name__))
    583 
    584     def __repr__(self):
ValueError: 2 is not a valid PublicationSource

I appreciate if anyone could help me with this. Thank you.



Sources

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

Source: Stack Overflow

Solution Source