Skip to main content

File handling library for creating, saving, and loading various file types (CSV, JSON, JOBLIB, PDF)

Project description

dsr-files

PyPI version Python versions License Changelog

File handling library for creating, saving, and loading various file types.

Version 1.0.0: This release is breaking and not backward-compatible with prior 0.x versions.

Features

  • CSV: Read and write CSV files with pandas
  • JSON: Save and load JSON data structures
  • JOBLIB: Serialize Python objects with joblib
  • Excel: Save and load Excel workbooks (single or multi-sheet)
  • PDF: Generate PDF documents with text content

Installation

pip install dsr-files

Development Installation

pip install -e ".[dev]"

Usage

CSV Operations

from dsr_files import save_csv, load_csv, create_csv
import pandas as pd
from pathlib import Path

# Create from dictionary
data = {"name": ["Alice", "Bob"], "age": [30, 25]}
df = create_csv(data)

# Save to CSV
save_csv(df, Path("."), "data")

# Load from CSV
df = load_csv(Path("data.csv"))

JSON Operations

from dsr_files import save_json, load_json
from pathlib import Path

data = {"key": "value", "number": 42}

# Save to JSON
save_json(data, Path("."), "data")

# Load from JSON
data = load_json(Path("data.json"))

JOBLIB Operations

from dsr_files import save_joblib, load_joblib
from pathlib import Path

# Save any Python object
model = {"weights": [1, 2, 3], "config": {}}
save_joblib(model, Path("."), "model")

# Load from JOBLIB
model = load_joblib(Path("model.joblib"))

Excel Operations

from dsr_files import save_excel, load_excel, ExcelSheetConfig
from pathlib import Path
import pandas as pd

sales = pd.DataFrame({"region": ["NA", "EU"], "revenue": [120, 95]})
costs = pd.DataFrame({"region": ["NA", "EU"], "cost": [80, 70]})

# Save multi-sheet workbook
save_excel(
	[
		ExcelSheetConfig(data=sales, sheet_name="Sales"),
		ExcelSheetConfig(data=costs, sheet_name="Costs"),
	],
	Path("."),
	"report",
)

# Load first sheet
df = load_excel(Path("report.xlsx"))

PDF Operations

from dsr_files import save_pdf
from pathlib import Path

# Save text to PDF
content = "Hello, World!\nThis is a PDF document."
save_pdf(content, Path("."), "document", title="My Document")

Testing

pytest tests/
pytest tests/ --cov=src/dsr_files

License

MIT

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

dsr_files-1.0.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

dsr_files-1.0.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file dsr_files-1.0.0.tar.gz.

File metadata

  • Download URL: dsr_files-1.0.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dsr_files-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e55310f96a45cb00838f3b7dba6cabd16085b9f9e48ee138f6f72f509bea790e
MD5 0af830fc958315df3a48720351ad4a6c
BLAKE2b-256 012a340ba8c999087c243517a6ea3355ec6250dfedb4a6ca127230a2161cf22e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dsr_files-1.0.0.tar.gz:

Publisher: python-publish.yml on scottroberts140/dsr-files

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dsr_files-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dsr_files-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dsr_files-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8012b96115263fe7b9ca5f999883660467087ba381d064c9cb80ac281b3f3fe
MD5 c61ed823b822bdc43893b0505ed57b8d
BLAKE2b-256 dc82a87f2cfbda47fdc8159c87d5fb3901bf9b7f1ef836d6acb24dd2bd309279

See more details on using hashes here.

Provenance

The following attestation bundles were made for dsr_files-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on scottroberts140/dsr-files

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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