Skip to main content

data loading,writing, transforming without third party library

Project description

happydata

happy data loading,writing, transforming without third party library

Installation

pip install happydata

Usage

from happydata import *
import io

class User:
    def __init__(self, name:str, age:int):
        self.name = name
        self.age = age
tmp_path = 'test_users.jsonl'
# jsonl
write_jsonl([User('name', 18), User('张三', 19)], tmp_path)
assert load_jsonl(tmp_path) == [{'name': 'name', 'age': 18}, {'name': '张三', 'age': 19}]

# jsonl.gz
records = load_jsonl_gz('test_users.jsonl.gz')
write_jsonl_gz(records, 'test_users.jsonl.gz')
# lines
for line in read_lines('test_users.jsonl'):
    print(line)
write_lines(lines, 'test_users.jsonl')

# tar.gz
for item, f in read_tar_gz(tmp_path):
    print(item.name)
    bs= f.read()
write_tar_gz(records, {
    'test.txt': io.BytesIO(b'hello'),
    }, 'test.tar.gz')

# zip
for name, f in read_zip(tmp_path):
    print(name)
    bs = f.read()
write_zip({
    'test.txt': io.BytesIO(b'hello'),
    }, 'test.zip')

# dir
files = load_dir('test_dir')

# commands:
state,stdout,stderr = run('ls')

# transform:
groupby([{'name': 'name', 'age': 18}, {'name': '张三', 'age': 19}], 'name')

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

happydata-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

happydata-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file happydata-0.1.0.tar.gz.

File metadata

  • Download URL: happydata-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for happydata-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d4664e3e04ea019ebcee92656849cbb6849353d4d844c18664cf51845e6310ae
MD5 c98ef1e7e854b9d9b43f756356b78ccc
BLAKE2b-256 934550c93a071fca7dbc4e21ace10d9e7fa984a2fb5c706f46ba8cc78a0afa55

See more details on using hashes here.

File details

Details for the file happydata-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: happydata-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for happydata-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05612616a4e3dbf68e3fb8d2895908cdf8877683c87a48953c7354dece2007c6
MD5 6def2cb5fbfd833deb59813b7256f2bb
BLAKE2b-256 510256645bd8f7f92ff27342426c8ecdb5cc52cbe3873900680e85d8d1464ccf

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