Skip to main content

Simple wrappers to load and convert common data file types

Project description

https://img.shields.io/pypi/v/pandect.svg https://img.shields.io/travis/datagazing/pandect.svg Documentation Status

Simple wrappers to load and convert common data file types

Features

  • Uses file extension as heuristic to determine input format

  • Provides metadata using pyreadstat objects when appropriate

  • Supports: csv, tsv, xlsx, sav, dta (unreliable), sqlite3

  • Loads data into pandas.DataFrame

  • Provides command line utilities: sav2dta, pandect

Examples

Load a data file into a pandas.DataFrame object:

>>> import pandect
>>> data, meta = pandect.load(input_file_name)

Save a pandas.DataFrame object as a data file:

>>> import pandas
>>> import pandect
>>> data = pandas.DataFrame([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}])
>>> pandect.save(data=data, output='out.sav')
>>>

Save a pandas.DataFrame object as a data file with metadata:

>>> import pandas
>>> import pandect
>>> import pyreadstat
>>> data = pandas.DataFrame([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}])
>>> meta = pyreadstat.metadata_container()
>>> meta.column_names_to_labels = {'a': 'A Label', 'b': 'B Label'}
>>> pandect.save(data=data, output='out.sav', meta=meta)
>>>

Convert a data file at the command line:

$ pandect input.csv output.dta

Convert sav data file to dta data file:

$ sav2dta some_file.sav
  • Derives output file name from input file name (here: some_file.dta)

  • This is a convenience utility for a common task

  • It is basically a special case of the pandect utility

Limitations

  • Loading dta files is unreliable (bug in pyreadstat, might segfault)

License

  • Free software: MIT license

Documentation

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

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

pandect-0.4.0.tar.gz (28.7 kB view hashes)

Uploaded Source

Built Distribution

pandect-0.4.0-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

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