All Projects → Pytlicek → sheet2dict

Pytlicek / sheet2dict

Licence: MIT license
Simple XLSX and CSV to dictionary converter

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to sheet2dict

eec
A fast and lower memory excel write/read tool.一个非POI底层,支持流式处理的高效且超低内存的Excel读写工具
Stars: ✭ 93 (-54.85%)
Mutual labels:  csv, excel, xlsx, worksheet
Spreadsheet architect
Spreadsheet Architect is a library that allows you to create XLSX, ODS, or CSV spreadsheets super easily from ActiveRecord relations, plain Ruby objects, or tabular data.
Stars: ✭ 1,160 (+463.11%)
Mutual labels:  export, csv, xlsx, spreadsheet
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+13724.76%)
Mutual labels:  csv, excel, xlsx, spreadsheet
spreadsheet
Yii2 extension for export to Excel
Stars: ✭ 79 (-61.65%)
Mutual labels:  export, excel, xlsx, spreadsheet
XToolset
Typed import, and export XLSX spreadsheet to JS / TS. Template-based create, render, and export data into excel files.
Stars: ✭ 110 (-46.6%)
Mutual labels:  excel, xlsx, spreadsheet, worksheet
J
❌ Multi-format spreadsheet CLI (now merged in http://github.com/sheetjs/js-xlsx )
Stars: ✭ 343 (+66.5%)
Mutual labels:  csv, excel, xlsx, spreadsheet
Tableexport
The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
Stars: ✭ 781 (+279.13%)
Mutual labels:  export, csv, excel, xlsx
Yii2 Export
A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)
Stars: ✭ 153 (-25.73%)
Mutual labels:  export, excel, spreadsheet
Portphp
Data import/export framework for PHP
Stars: ✭ 225 (+9.22%)
Mutual labels:  export, csv, excel
umya-spreadsheet
A pure rust library for reading and writing spreadsheet files
Stars: ✭ 79 (-61.65%)
Mutual labels:  excel, xlsx, spreadsheet
xlsx-reader
xlsx-reader is a PHP library for fast and efficient reading of XLSX spreadsheet files. Its focus is on reading the data contained within XLSX files, disregarding all document styling beyond that which is strictly necessary for data type recognition. It is built to be usable for very big XLSX files in the magnitude of multiple GBs.
Stars: ✭ 40 (-80.58%)
Mutual labels:  excel, xlsx, spreadsheet
Sonar Cnes Report
Generates analysis reports from SonarQube web API.
Stars: ✭ 145 (-29.61%)
Mutual labels:  export, csv, xlsx
Pyetl
python ETL framework
Stars: ✭ 33 (-83.98%)
Mutual labels:  export, csv, excel
spreadcheetah
SpreadCheetah is a high-performance .NET library for generating spreadsheet (Microsoft Excel XLSX) files.
Stars: ✭ 107 (-48.06%)
Mutual labels:  excel, xlsx, spreadsheet
MiniExcel
Fast, Low-Memory, Easy Excel .NET helper to import/export/template spreadsheet
Stars: ✭ 996 (+383.5%)
Mutual labels:  csv, excel, xlsx
Excellentexport
Javascript export to Excel
Stars: ✭ 1,018 (+394.17%)
Mutual labels:  export, csv, excel
fxl
fxl is a Clojure spreadsheet library
Stars: ✭ 117 (-43.2%)
Mutual labels:  excel, xlsx, spreadsheet
xltpl
A python module to generate xls/x files from a xls/x template.
Stars: ✭ 46 (-77.67%)
Mutual labels:  excel, xlsx, spreadsheet
Dexiom.EPPlusExporter
A very simple, yet incredibly powerfull library to generate Excel documents out of objects, arrays, lists, collections, etc.
Stars: ✭ 19 (-90.78%)
Mutual labels:  excel, xlsx, spreadsheet
Laracsv
A Laravel package to easily generate CSV files from Eloquent model
Stars: ✭ 583 (+183.01%)
Mutual labels:  export, csv, excel

Test Python package codecov Upload Python Package to PyPI PythonVersions Sourcery Black Snyk Downloads Twitter Follow

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
Spreadsheets with multiple worksheets are supported. If no sheet is specified, the active sheet is selected. If there is only one sheet, it is considered active.

# Import the library
from sheet2dict import Worksheet

# Create an object
ws = Worksheet()

# Convert active sheet (without specifying sheet name)
ws.xlsx_to_dict(path='inventory.xlsx')

# Convert the 'Main Warehouse' sheet of the 'inventory.xslx' spreadsheet file.
ws.xlsx_to_dict(path='inventory.xlsx', select_sheet='Main Warehouse')

# 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 library
from sheet2dict import Worksheet

# Example: read spreadsheet as object
path = 'inventory.xlsx'
xlsx_file = open(path, 'rb')
xlsx_file = BytesIO(xlsx_file.read())

# Parse spreadsheet from object
ws = Worksheet()
ws.xlsx_to_dict(path=xlsx_file)
print(ws.header)

- CSV

Use csv_to_dict() method when converting form csv.
CSV is a format with many variations, better handle encodings and delimiters on user side and not within module itself.

# Import the library
from sheet2dict import Worksheet

# Create an object
ws = Worksheet()

# Read CSV file
csv_file = open('inventory.csv', 'r', encoding='utf-8-sig')

# Convert 
ws.csv_to_dict(csv_file=csv_file, delimiter=';')

# 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)

- Other functions

Worksheet object.header returns first row with the data in a spreadsheet

Python 3.9.1
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
>>> from sheet2dict import Worksheet
>>> ws = Worksheet()
>>> ws.xlsx_to_dict(path="inventory.xlsx")

>>> ws.header
{'country': 'SK', 'city': 'Bratislava', 'citizens': '400000', 'random_field': 'cc'}

Worksheet object.sanitize_sheet_items removes None or empty dictionary keys from sheet_items

>>> from sheet2dict import Worksheet
>>> ws = Worksheet()
>>> ws.xlsx_to_dict(path="inventory.xlsx")

>>> ws.sheet_items
[
  {'country': 'CZ', 'city': 'Prague', 'citizens': '600000', None: '22', 'random_field': 'cc'},
  {'country': 'UK', 'city': 'London', 'citizens': '2000000', None: '33', 'random_field': 'cc'}
]

>>> ws.sanitize_sheet_items
[
  {'country': 'CZ', 'city': 'Prague', 'citizens': '600000', 'random_field': 'cc'},
  {'country': 'UK', 'city': 'London', 'citizens': '2000000', 'random_field': 'cc'}
]

Contributing and Code of Conduct

Contributing to sheet2dict

As an open source project, sheet2dict welcomes contributions of many forms.
Please read and follow our Contributing to sheet2dict

Contributors:

  • Thanks to 白一百 (bái-yī-bǎi) for making sheet2dict work with multi-sheet Excel files.

Code of Conduct

As a contributor, you can help us keep the sheet2dict project open and inclusive.
Please read and follow our Code of Conduct

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].