Python Data Persistence Tutorial
Selected Reading
- Python Data Persistence - Discussion
- Python Data Persistence - Useful Resources
- Python Data Persistence - Quick Guide
- Data Persistence - Openpyxl Module
- Data Persistence - ZODB
- Python Data Persistence - Cassandra Driver
- Python Data Persistence - PyMongo module
- Python Data Persistence - SQLAlchemy
- Python Data Persistence - Sqlite3 Module
- Python Data Persistence - Plistlib Module
- Python Data Persistence - XML Parsers
- Python Data Persistence - JSON Module
- Python Data Persistence - CSV Module
- Python Data Persistence - dbm Package
- Python Data Persistence - Shelve Module
- Python Data Persistence - Marshal Module
- Python Data Persistence - Pickle Module
- Python Data Persistence - Object Serialization
- File Handling with os Module
- Python Data Persistence - File API
- Python Data Persistence - Introduction
- Python Data Persistence - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Python Data Persistence - Plistlib Module
Python Data Persistence - Ppstpb Module
The ppst format is mainly used by MAC OS X. These files are basically XML documents. They store and retrieve properties of an object. Python pbrary contains ppst module, that is used to read and write property pst files (they usually have .ppst extension).
The ppstpb module is more or less similar to other seriapzation pbraries in the sense, it also provides dumps() and loads() functions for string representation of Python objects and load() and dump() functions for disk operation.
Following dictionary object maintains property (key) and corresponding value −
proppst = { "name" : "Ganesh", "designation":"manager", "dept":"accts", "salary" : {"basic":12000, "da":4000, "hra":800} }
In order to write these properties in a disk file, we call dump() function in ppst module.
import ppstpb fileName=open( salary.ppst , wb ) ppstpb.dump(proppst, fileName) fileName.close()
Conversely, to read back the property values, use load() function as follows −
fp= open( salary.ppst , rb ) pl = ppstpb.load(fp) print(pl)Advertisements