Skip to main content

dconvert

dconvert is a command-line tool that allows you to easily convert data files between various formats, including JSON, CSV, XML, HTML, and XLSX. The tool supports advanced options such as newline-delimited JSON, inclusion/exclusion of row indices, and automatic format inference based on file extensions.

Features

  • Convert between JSON, CSV, XML, HTML, and XLSX formats.
  • Support for newline-delimited JSON (jsonlines).
  • Option to include or exclude row indices in the output.
  • Automatic detection of input and output file formats based on file extensions.
  • Simple and intuitive command-line interface.

Installation

pip install dconvert

or...

Clone this repository and navigate to the project directory:

git clone https://github.com/aaronlmathis/dconvert.git
cd dconvert

Install the required dependencies.

pip install -r requirements.txt

Usage

The dconvert tool provides a flexible way to convert data files. Below is a comprehensive guide on how to use it.

###Basic Command Structure The basic command structure includes specifying the input file, output file, and desired output format. Optional arguments allow you to specify the input file type, whether to use newline-delimited JSON, and whether to include the row index in the output.

Required Arguments

  • --input: Path to the input file to be converted.
  • --outfile: Path to the converted output file.
  • --format: The desired output format. Accepted values are csv, json, html, xml, xlsx.

Optional Arguments

  • --inputfiletype: The type of the input file. Accepted values are csv, json, html, xml, xlsx. If not provided, dconvert will try to infer the input file type from the file extension.
  • --jsonlines: Whether to output JSON as newline-delimited (true for newline-delimited, false for a single JSON array). Defaults to false if not specified.
  • --index: Whether to include the row index in the output (true to include, false to exclude). Defaults to false if not specified.

Examples

Convert a CSV file to JSON as a single JSON array.

dconvert -i my_file.csv -o my_file.json

Convert an XLSX file to JSON with each row as a separate JSON object on a new line.

dconvert -i my_file.xlsx -o my_file.json -l 

Convert a JSON file to CSV and include the row indices in the output.

dconvert -i my_file.json -o my_file.csv -index

Convert an HTML file to XML and exclude the row indices.

dconvert -i my_file.html -o my_file.xml

##Error Handling If the output format is not specified and cannot be inferred from the output file extension, dconvert will raise an error. If the input file type is not specified and cannot be inferred from the input file extension, dconvert will raise an error.

File Formats Supported

  • JSON: JavaScript Object Notation, supports both single array and newline-delimited formats.
  • CSV: Comma-Separated Values, a simple text format for tabular data.
  • XML: Extensible Markup Language, used for structured data interchange.
  • HTML: HyperText Markup Language, typically used for web pages but also useful for tabular data.
  • XLSX: Microsoft Excel Open XML Spreadsheet format.

Contributing

If you'd like to contribute to dconvert, please fork the repository and submit a pull request. You can also open issues for feature requests or bugs.

License

This project is licensed under the GPL 3.0 License - see the LICENSE file for details.

Contact

For any questions, feel free to contact the project maintainer.

This is the complete README.md content without any code snippets or markdown-specific formatting.

Release files for dconvert 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dconvert 1.0
File Size Uploaded
dconvert-1.0.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dconvert 1.0
File Interpreter ABI Platform
dconvert-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.9 kB

Release files / dconvert-1.0.tar.gz

Download URL dconvert-1.0.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
18adeff94bde70658c1ca7bd831c4047f846ae581eb5603b8e086080261e9c65
BLAKE2b-256 checksum
How to use checksums
65fa7a78b3e4bdefda577222affa044a580ea106957f80c37e56992ab3aeba95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / dconvert-1.0-py3-none-any.whl

Download URL dconvert-1.0-py3-none-any.whl
Size 20.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a77ad6b1ce0820e07ee8e375bc12e0162de27b9f7049304a96a8126e8d0d68db
BLAKE2b-256 checksum
How to use checksums
e4b1d9f1b3022749e6e80c4c32109e68fdb3e3c0fb19d5b0761c1136eea2bbe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page