Skip to main content

A simple utility for converting formats to different and vice versa.

Project description

Shiftify Downloads Repo Size

Shiftify is a versatile Python package that provides efficient tools for converting data between a wide variety of formats. Whether your source data is in CSV or JSON format, Shiftify offers a comprehensive set of conversion tools—including SQL, HTML, plain text, YAML, XML, TSV, TOML, NDJSON, Excel, Markdown, binary (via pickle), and INI formats. It is designed to handle large files efficiently through streaming.

Features

CSV Conversions

  • CSV to JSON: Convert CSV files into JSON arrays.
  • CSV to SQL: Generate SQL INSERT statements from CSV rows.
  • CSV to HTML: Create an HTML table representation of CSV data.
  • CSV to Plain Text: Write each CSV row as a pretty‐printed JSON string on a new line.
  • CSV to YAML: Convert CSV files to YAML (with optional key wrapping).
  • CSV to XML: Convert CSV rows to XML where each row is an <Item> element.
  • CSV to TSV: Transform CSV files into tab-separated values.
  • CSV to TOML: Convert CSV rows to TOML format.
  • CSV to NDJSON: Generate newline-delimited JSON (NDJSON) from CSV rows.
  • CSV to Excel: Convert CSV files into Excel spreadsheets.
  • CSV to Markdown Table: Create Markdown formatted tables from CSV data.
  • CSV to Binary: Serialize CSV rows into a binary file using pickle.
  • CSV to INI: Convert CSV data into an INI file, storing each row as a separate section.

JSON Conversions

  • JSON to CSV: Convert JSON arrays into CSV format.
  • JSON to SQL: Generate SQL INSERT statements from JSON objects.
  • JSON to HTML: Create an HTML table representation of JSON data.
  • JSON to Plain Text: Write each JSON object as a pretty‐printed string on a new line.
  • JSON to YAML: Convert JSON arrays to YAML (with optional key wrapping).
  • JSON to XML: Convert JSON arrays to XML where each object is an <Item> element.
  • JSON to TSV: Transform JSON data into TSV format.
  • JSON to TOML: Convert JSON arrays to TOML format.
  • JSON to NDJSON: Generate newline-delimited JSON (NDJSON) from JSON objects.
  • JSON to Excel: Convert JSON arrays into Excel spreadsheets.
  • JSON to Markdown Table: Create Markdown tables from JSON data.
  • JSON to Binary: Serialize JSON objects into a binary file using pickle.
  • JSON to INI: Convert JSON arrays into an INI file, storing each object as a separate section.

Installation

To install Shiftify, run the following command in your terminal:

pip install Shiftify

Usage

Shiftify provides two main classes—CSV and JSON—that handle conversions from CSV and JSON files respectively. (Will roll out new formats soon)

Using the CSV Class

from shiftify import CSV

# Initialize the CSV converter with your CSV file
csv_converter = CSV('path/to/your/input.csv')

# Convert CSV to JSON
csv_converter.to_json('path/to/your/output.json')

# Convert CSV to SQL (and save the SQL statements to a file)
csv_converter.to_sql('path/to/your/output.sql', table_name="my_table")

# Convert CSV to HTML table
csv_converter.to_html('path/to/your/output.html')

# Convert CSV to YAML (with optional key wrapping)
csv_converter.to_yaml('path/to/your/output.yaml', key="record")

# Convert CSV to XML with a custom root element
csv_converter.to_xml('path/to/your/output.xml', root_element="Data")

# Other conversions include:
# to_text, to_tsv, to_toml, to_ndjson, to_excel, to_markdown_table, to_binary, and to_ini.

Using the JSON Class

from shiftify import JSON

# Initialize the JSON converter with your JSON file
json_converter = JSON('path/to/your/input.json')

# Convert JSON to CSV
json_converter.to_csv('path/to/your/output.csv')

# Convert JSON to SQL statements
json_converter.to_sql('path/to/your/output.sql', table_name="my_table")

# Convert JSON to HTML table
json_converter.to_html('path/to/your/output.html')

# Convert JSON to YAML (with optional key wrapping)
json_converter.to_yaml('path/to/your/output.yaml', key="record")

# Convert JSON to XML with a custom root element
json_converter.to_xml('path/to/your/output.xml', root_element="Data")

# Other conversions include:
# to_text, to_tsv, to_toml, to_ndjson, to_excel, to_markdown_table, to_binary, and to_ini.

Customizing Options

For CSV-to-JSON (or vice versa) conversions, you can customize options such as delimiters and quote characters. For example:

from shiftify import JSON

json_converter = JSON('path/to/your/input.json')
# Use a semicolon as delimiter and a single quote as quotechar when converting to CSV
json_converter.to_csv('path/to/your/output.csv', delimiter=';', quotechar="'")

Contributing

Contributions to Shiftify are welcome! Please feel free to fork the repository, make your improvements, and submit a pull request. Whether you're fixing bugs, adding new conversion formats, or improving the documentation, your help is appreciated.

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shiftify-0.1.4.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shiftify-0.1.4-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file shiftify-0.1.4.tar.gz.

File metadata

  • Download URL: shiftify-0.1.4.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for shiftify-0.1.4.tar.gz
Algorithm Hash digest
SHA256 af5d4d8563b409ff77aeac846d631c932605984a21e5eb37893ef90ee5ede1c6
MD5 b20a1167c74f74365c4c4ec2769f22e7
BLAKE2b-256 09c051adaa40b12f98bb60e1416bc04feb05061754508e0d7e1e3b061ba6101d

See more details on using hashes here.

File details

Details for the file shiftify-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: shiftify-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for shiftify-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a79991c534109b40681274b3ddf370169fbf61e3647966ccf4fe94c7036a9efe
MD5 bda16628e5daa2a178dedfb8f5a6d7e7
BLAKE2b-256 e3471c8cfbdaccaf88423aaf1aea61af2dc5d9edcd0ab207bb2943a3a1b6b560

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page