spreadsheet-to-json-0.1.4 has been yanked.
spreadsheet-to-json
Convert Spreadsheets and CSV files to jSON
This library crate provides the core functions to convert common spreadsheet and CSV files into JSON or JSONL (JSON Lines) either directly or asynchronously.
It relies on the Calamine and CSV library crates to process files, the tokio crate for asynchronous operations and naturally serde and serde_json serialization libraries.
It supports the following formats:
- Excel 2007+ Workbook (.xlsx)
- Excel 2007+ Binary (.xlsb)
- Excel 97-2004 Legacy (.xls)
- OpenDocument Spreadsheets (.ods) compatible with LibreOffice
- CSV: comma separated values (.csv)
- TSV: tab-separated values (.tsv)
Features
- Blazingly fast. It can import 10,000 rows in 0.4 seconds.
- Can export to standard JSON or to JSON lines when writing large files
- Formula cells are read as calculated values
- Can identify and convert both Excel's 1900 datetime format and standard ISO format as used in OpenDocument Spreadsheet
- Can identify numeric fields formatted as text and convert them to integers or floats.
- Can identify truthy text or number cells and convert them to booleans
- Can save large files asynchronously
To do
Full explanation of options to come.
Alpha warning
This crate is still alpha and likely to undergo breaking changes as it's part of larger data import project. I do not expect a stable version before mid January when it has been battle-tested.
- 0.1.2 the core public functions with Result return types now use a GenericError error type
- 0.1.3 Refined A1 and C01 column name styles and added result output as vectors of lines for interoperability with CLI utilities and debugging.
- 0.1.4 Added support for Excel Binary format (.xlsb)
Examples
The main implementation is my unpublished Spreadsheet to JSON CLI crate,
Simple immediate jSON conversion
This must be called in an async function.
use *;
use tokio;
async
Asynchronous parsing saving to a database
This must be called in an async function.
use *;
use tokio;
async