Skip to main content

Tabular_2_Text

Sometimes text-heavy spreadsheets are easier to read as text files!

Sometimes tabular data is just easier to read as text!

Tabular_2_Text is a Python package that converts tabular data (CSV files or pandas DataFrames) into a formatted text file. Each row from your table is converted into a clearly formatted text entry with labeled fields.

Features

  • Convert CSV files directly to formatted text
  • Convert pandas DataFrames to formatted text
  • Clean, readable output format
  • Automatic field labeling
  • Simple, user-friendly interface

Installation

pip install tabular-2-text

Usage

Basic Usage

from tabular_2_text import tab2text

# Using a CSV file as input
tab2text("input.csv", "output.txt")

# Using a pandas DataFrame as input
import pandas as pd
df = pd.DataFrame({
    'name': ['John Doe', 'Jane Smith'],
    'age': [30, 25],
    'city': ['New York', 'Los Angeles']
})
tab2text(df, "output.txt")

Example

Input CSV (employees.csv):

name,age,department,salary
John Doe,30,Engineering,75000
Jane Smith,28,Marketing,65000
Bob Johnson,35,Sales,70000

Python code:

from converter import tab2text

# Convert the CSV to text
tab2text("employees.csv", "employees_formatted.txt")

Output (employees_formatted.txt):

name: John Doe
age: 30
department: Engineering
salary: 75000

***********************************************

name: Jane Smith
age: 28
department: Marketing
salary: 65000

***********************************************

name: Bob Johnson
age: 35
department: Sales
salary: 70000

Function Parameters

tab2text(input_data, output_file_path)

  • input_data: Either a file path to a CSV file (string) or a pandas DataFrame
  • output_file_path: The path where you want to save the output text file (string)

Returns

  • Returns the path to the generated text file (string)
  • Prints a confirmation message with the file location

Requirements

  • Python 3.6 or higher
  • pandas

Error Handling

The function will raise a ValueError if:

  • The input is neither a string (file path) nor a pandas DataFrame
  • The CSV file path is invalid
  • The DataFrame is empty

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Common Use Cases

  1. Converting spreadsheet data to readable text format
  2. Preparing tabular data for document integration
  3. Creating human-readable exports from databases
  4. Formatting data for report generation
  5. Converting CSV exports to readable text

Tips

  • Make sure your CSV files are properly formatted
  • For large datasets, consider processing in chunks
  • Check that your output filepath is writable
  • Keep column names simple and readable for best results

Metadata

Release files for tabular-2-text 0.1.7

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

Source distribution (sdist)

Source distribution for tabular-2-text 0.1.7
File Size Uploaded Provenance
tabular_2_text-0.1.7.tar.gz 4.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tabular-2-text 0.1.7
File Interpreter ABI Platform
tabular_2_text-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 8.5 kB

Release files / tabular_2_text-0.1.7.tar.gz

Download URL tabular_2_text-0.1.7.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3e993c0ca2f5f65bd8b94fe34b69e9c39987244963dd873cb72821570eacbdb1
BLAKE2b-256 checksum
How to use checksums
5bf8fe8c4c187612ec9339aab3706fe376ffddbd763df863e70acb44c29be139
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Release files / tabular_2_text-0.1.7-py3-none-any.whl

Download URL tabular_2_text-0.1.7-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c31c4d717c70d01306705a30ad6d4cb1b7b0cee26cbb676536ce96571418c2b6
BLAKE2b-256 checksum
How to use checksums
7137d22e6e43bdb079ae8c6a858c67d9c0991a5565a7cbe26fb321caab7b84e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Security for tabular-2-text 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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