Every line of 'read pickle file' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
4 def load_pickle(file_name): 5 '''Easy interface to Python cPickle persistence module. 6 7 :: 8 9 abjad> t = Note(0, (1, 4)) 10 abjad> f(t) 11 c'4 12 abjad> iotools.dump_pickle(t, 'temp.pkl') 13 14 :: 15 16 abjad> new = iotools.load_pickle('temp.pkl') 17 abjad> new 18 Note(c', 4) 19 20 .. versionchanged:: 1.1.2 21 renamed ``persistencetools.pickle_load( )`` to 22 ``iotools.load_pickle( )``. 23 24 .. versionchanged:: 1.1.2 25 renamed ``persistencetools.load_pickle( )`` to 26 ``iotools.load_pickle( )``. 27 ''' 28 29 f = open(file_name, 'r') 30 data = cPickle.load(f) 31 f.close( ) 32 return data
114 def load_dump(pickle_file): 115 with open(pickle_file, 'rb') as f: 116 data = pickle.load(f, encoding='bytes') 117 return data
49 def read_pkl(pkl): 50 with open(pkl, "rb") as f: 51 obj = pickle.load(f) 52 return obj
11 def unpickle(file): 12 fo = open(file, 'rb') 13 dict = cPickle.load(fo) 14 fo.close() 15 return dict
10 def load_pickle(filename): 11 pkl_file = open(filename, 'rb') 12 data = pickle.load(pkl_file) 13 return data
101 def pickle_from_file(path): 102 """Load the pickle file from the provided path and returns the object.""" 103 return pickle.load(open(path, 'rb'))
12 def _safe_unpickle(file_name): 13 with open(file_name, "rb") as data_file: 14 if sys.version_info >= (3, 0): 15 # python3 unpickling of python2 unicode 16 data = pickle.load(data_file, encoding="latin1") 17 else: 18 data = pickle.load(data_file) 19 return data
16 @staticmethod 17 def read_file(read_dir, read_prefix, batch_count): 18 read_name = (("%s(%i).pkl.gz") % (read_prefix, batch_count)) 19 open_name = os.path.join(os.path.split(__file__)[0], "..", read_dir, 20 read_name) 21 with gzip.open(open_name, 'rb') as f: 22 set_x, set_y = cPickle.load(f) 23 24 # print len(set_x), set_x[0].shape 25 26 data_x = numpy.asarray(set_x, dtype=theano.config.floatX) 27 data_y = numpy.asarray(set_y, dtype='int32') 28 print (("File %s is loaded") % (read_name)) 29 return data_x, data_y
185 def gunpickle(filename): 186 return pickle.load(gzip.open(filename, 'rb'))
391 def pickle_load(path, filename): 392 """ 393 Save data to Pickle file (*.pkl). Allows saving dictionary or other 394 data in a way that json cannot always be saved due to json formatting 395 rules. 396 397 :Args: 398 :path: path to file (no trailing slash) 399 :filename: filename including extension 400 :data: Data to be pickled. 401 :encoding: 'Machine' or 'Human' - determines whether file contents 402 can be viewed in a text editor. 403 404 :returns: saved data. (Assumes success; errors will raise exception.) 405 406 """ 407 with open("%s/%s" % (path, filename), "rb") as f: 408 return Pickle.load(f)