Skip to content

Latest commit

 

History

History
56 lines (34 loc) · 2.19 KB

Python_Read_pickle_file.md

File metadata and controls

56 lines (34 loc) · 2.19 KB



Template request | Bug report | Generate Data Product

Tags: #python #pickle #file #load #data #io

Author: Kaushal Krishna

Description:
This notebook loads a dictionary from pickle object. Loading a dictionary using pickle is a quick and easy process. With just a few lines of code, you can store your dictionary data from a pickle file.

Pickle can cause critical security vulnerabilities in code, you should never unpickle data you don’t trust. If you must accept data from an untrusted client, you should use the safer JSON format. And, if you transfer pickled data between trusted applications but need extra measures to prevent tampering, you should generate an HMAC signature you can verify before unpickling.

References:

Input

Import libraries

import pickle

Setup Variables

  • data: a variable to store unpickled object
  • input_path: pickle file source
# Inputs
input_path = "data.pkl"

# Outputs
data = None

Model

Load dictionary from pickle file

Using the pickle.load() function, the data dictionary can be loaded into from a pickle file.

with open(input_path, "rb") as f:
    data=pickle.load(f)

Output

Display result

print("The unpickled object is : \n", data)