Simple XLSX and CSV to dictionary converter with python
sheet2dict
A simple XLSX/CSV reader – to dictionary converter
Installing
To install the package from pip, first run:
python3 -m pip install --no-cache-dir sheet2dict
Required pip packages for sheet2doc: csv, openpyxl
Usage
This library has 2 main features: reading a spreadsheet files and converting them to array of python dictionaries.
– XLSX
Use xlsx_to_dict()
method when converting form spreadsheets.
Supported file formats for spreadsheets are: .xlsx,.xlsm,.xltx,.xltm
# Import the library
from sheet2dict import Worksheet
# Create an object
ws = Worksheet()
# Convert
ws.xlsx_to_dict(path='inventory.xlsx')
# object.header returns first row with the data in a spreadsheet
print(ws.header)
# object.sheet_items returns converted rows as dictionaries in the array
print(ws.sheet_items)
You can parse data when worksheet is an object
# Import the