build_tools.corpus_db_viewer.formatters
Export formatters for corpus database viewer.
Provides functions to export database query results to various formats.
Functions
|
Export data to CSV format. |
|
Export data to JSON format. |
|
Format row count with thousands separator. |
|
Format file size in human-readable format. |
Module Contents
- build_tools.corpus_db_viewer.formatters.export_to_csv(rows, output_path)[source]
Export data to CSV format.
Parameters
- rowslist[dict[str, Any]]
List of row data as dictionaries
- output_pathPath
Path where CSV file will be written
Raises
- ValueError
If rows list is empty
Examples
>>> rows = [ ... {'id': 1, 'name': 'Alice', 'age': 30}, ... {'id': 2, 'name': 'Bob', 'age': 25} ... ] >>> export_to_csv(rows, Path("_working/exports/data.csv"))
- build_tools.corpus_db_viewer.formatters.export_to_json(rows, output_path)[source]
Export data to JSON format.
Parameters
- rowslist[dict[str, Any]]
List of row data as dictionaries
- output_pathPath
Path where JSON file will be written
Raises
- ValueError
If rows list is empty
Examples
>>> rows = [ ... {'id': 1, 'name': 'Alice', 'age': 30}, ... {'id': 2, 'name': 'Bob', 'age': 25} ... ] >>> export_to_json(rows, Path("_working/exports/data.json"))