A tool for converting data formats.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dconvert-1.0.tar.gz.
File metadata
- Download URL: dconvert-1.0.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18adeff94bde70658c1ca7bd831c4047f846ae581eb5603b8e086080261e9c65
|
|
| MD5 |
59185fbe329c8f68dcc12883674fcb4b
|
|
| BLAKE2b-256 |
65fa7a78b3e4bdefda577222affa044a580ea106957f80c37e56992ab3aeba95
|
File details
Details for the file dconvert-1.0-py3-none-any.whl.
File metadata
- Download URL: dconvert-1.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a77ad6b1ce0820e07ee8e375bc12e0162de27b9f7049304a96a8126e8d0d68db
|
|
| MD5 |
0a1120638cc6f4c1e5d8f699e2b8472a
|
|
| BLAKE2b-256 |
e4b1d9f1b3022749e6e80c4c32109e68fdb3e3c0fb19d5b0761c1136eea2bbe8
|