https://github.com/residentmario/datafy
Tiny single-function Python module for inspecting file structure.
https://github.com/residentmario/datafy
Last synced: over 1 year ago
JSON representation
Tiny single-function Python module for inspecting file structure.
- Host: GitHub
- URL: https://github.com/residentmario/datafy
- Owner: ResidentMario
- License: mit
- Created: 2017-01-24T03:38:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-12T19:25:49.000Z (almost 9 years ago)
- Last Synced: 2025-01-28T10:25:11.452Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 1.31 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## datafy [](https://pypi.python.org/pypi/datafy/) 
`datafy` is a tiny Python package that handles reading a list of files out of a number of common formats, including
recursively reading out the contents of a `ZIP` file.
`datafy` can read data from local files:
```
>>> from datafy import get
>>> get("file:///Desktop/myfile.csv")
<<< [{'filepath': '.',
'mimetype': 'text/csv',
'extension': 'csv'}]
```
As well as from the web:
```
>>> get("https://data.cityofnewyork.us/api/geospatial/arq3-7z49?method=export&format=GeoJSON")
<<< [{'filepath': '.',
'mimetype': 'text/json',
'extension': 'geojson'}]
```
It handles ZIP files as well:
```
>>> get("https://data.cityofnewyork.us/download/ft4n-yqee/application%2Fzip")
<<< [{'filepath': 'data.shp',
'mimetype': 'octet/stream',
'extension': 'shp'},
{...}]
```
### Development
To hack on `datafy`, clone this library locally. Install its dependencies (`requests`, `requests_file`,
`python-magic`) and development dependencies (`pytest`, `requests_mock`) via `pip`. If you have `conda`, you can run
`conda env create -f envs/devenv.yml` to do this for you.
To execute the test suite, run `pytest tests.py` on the command line from the `/tests` folder.
Pull requests welcome.
### Limitations
* Only handles archival files in the ZIP format, so no TAR files ecetera. ([#1](https://github.com/ResidentMario/datafy/issues/1)).
* Does not handle recursively archived files ([#2](https://github.com/ResidentMario/datafy/issues/2)).