csvdir


Namecsvdir JSON
Version 0.5.2 PyPI version JSON
download
home_pageNone
SummaryRead all csv files in a directory with one iterator.
upload_time2024-12-12 20:54:45
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License
keywords csv dict dir directory reader
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            A Python package used to iterate through a directory of csv files and read each row as a dict.

Install
```console
pip install csvdir
```

Examples
```sh
>>> import csvdir

>>> reader = csvdir.read_dir('data/')
>>> reader.names
['people1', 'people2']
>>> reader.paths
['data/people1.csv', 'data/people2.csv']

>>> for row in reader:
...    print(row)
...
{'id': '1', 'name': 'Odos', 'age': '38'},
{'id': '2', 'name': 'Kayla', 'age': '31'},
{'id': '3', 'name': 'Dexter', 'age': 'two'},
{'id': '4', 'name': 'Joe', 'age': '44'},
{'id': '5', 'name': 'James', 'age': '55'},
{'id': '6', 'name': 'Luke', 'age': '0'}

>>> for name, row in reader.with_names():
...    print(name, row)
...
'people1' {'id': '1', 'name': 'Odos', 'age': '38'},
'people1' {'id': '2', 'name': 'Kayla', 'age': '31'},
'people1' {'id': '3', 'name': 'Dexter', 'age': 'two'},
'people2' {'id': '4', 'name': 'Joe', 'age': '44'},
'people2' {'id': '5', 'name': 'James', 'age': '55'},
'people2' {'id': '6', 'name': 'Luke', 'age': '0'}

>>> for path, row in reader.with_paths():
...    print(path, row)
...
'data/people1.csv' {'id': '1', 'name': 'Odos', 'age': '38'},
'data/people1.csv' {'id': '2', 'name': 'Kayla', 'age': '31'},
'data/people1.csv' {'id': '3', 'name': 'Dexter', 'age': 'two'},
'data/people2.csv' {'id': '4', 'name': 'Joe', 'age': '44'},
'data/people2.csv' {'id': '5', 'name': 'James', 'age': '55'},
'data/people2.csv' {'id': '6', 'name': 'Luke', 'age': '0'}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "csvdir",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "csv, dict, dir, directory, reader",
    "author": null,
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "A Python package used to iterate through a directory of csv files and read each row as a dict.\n\nInstall\n```console\npip install csvdir\n```\n\nExamples\n```sh\n>>> import csvdir\n\n>>> reader = csvdir.read_dir('data/')\n>>> reader.names\n['people1', 'people2']\n>>> reader.paths\n['data/people1.csv', 'data/people2.csv']\n\n>>> for row in reader:\n...    print(row)\n...\n{'id': '1', 'name': 'Odos', 'age': '38'},\n{'id': '2', 'name': 'Kayla', 'age': '31'},\n{'id': '3', 'name': 'Dexter', 'age': 'two'},\n{'id': '4', 'name': 'Joe', 'age': '44'},\n{'id': '5', 'name': 'James', 'age': '55'},\n{'id': '6', 'name': 'Luke', 'age': '0'}\n\n>>> for name, row in reader.with_names():\n...    print(name, row)\n...\n'people1' {'id': '1', 'name': 'Odos', 'age': '38'},\n'people1' {'id': '2', 'name': 'Kayla', 'age': '31'},\n'people1' {'id': '3', 'name': 'Dexter', 'age': 'two'},\n'people2' {'id': '4', 'name': 'Joe', 'age': '44'},\n'people2' {'id': '5', 'name': 'James', 'age': '55'},\n'people2' {'id': '6', 'name': 'Luke', 'age': '0'}\n\n>>> for path, row in reader.with_paths():\n...    print(path, row)\n...\n'data/people1.csv' {'id': '1', 'name': 'Odos', 'age': '38'},\n'data/people1.csv' {'id': '2', 'name': 'Kayla', 'age': '31'},\n'data/people1.csv' {'id': '3', 'name': 'Dexter', 'age': 'two'},\n'data/people2.csv' {'id': '4', 'name': 'Joe', 'age': '44'},\n'data/people2.csv' {'id': '5', 'name': 'James', 'age': '55'},\n'data/people2.csv' {'id': '6', 'name': 'Luke', 'age': '0'}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Read all csv files in a directory with one iterator.",
    "version": "0.5.2",
    "project_urls": null,
    "split_keywords": [
        "csv",
        " dict",
        " dir",
        " directory",
        " reader"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3fc5c2459ec61010792d772ab43b00c5ab63d3fdba39c5143f0c271e1bee5f53",
                "md5": "bea2c9ee7825db2b4c8b82202ddacaf0",
                "sha256": "28153e0f451d6921d710e41e118a936e9dd477b06c7b5d66240c90744d8e0ee0"
            },
            "downloads": -1,
            "filename": "csvdir-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bea2c9ee7825db2b4c8b82202ddacaf0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 39328,
            "upload_time": "2024-12-12T20:54:45",
            "upload_time_iso_8601": "2024-12-12T20:54:45.227797Z",
            "url": "https://files.pythonhosted.org/packages/3f/c5/c2459ec61010792d772ab43b00c5ab63d3fdba39c5143f0c271e1bee5f53/csvdir-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-12 20:54:45",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "csvdir"
}
        
Elapsed time: 0.44122s