sas7bdat


Namesas7bdat JSON
Version 2.2.3 PyPI version JSON
download
home_pagehttps://bitbucket.org/jaredhobbs/sas7bdat
SummaryA sas7bdat file reader for Python
upload_time2019-07-15 15:29:53
maintainer
docs_urlNone
authorJared Hobbs
requires_python
licenseMIT
keywords sas sas7bdat csv converter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            sas7bdat.py
===========

This module will read sas7bdat files using pure Python (2.6+, 3+). No SAS software
required! The module started out as a port of the R script of the same name
found here: <https://github.com/BioStatMatt/sas7bdat> but has since been
completely rewritten.

Also included with this library is a simple command line script,
`sas7bdat_to_csv`, which converts sas7bdat files to csv files. It will also
print out header information and meta data using the `--header` option and it
will batch convert files as well. Use the `--help` option for more information.

As is, I've successfully tested the script almost three hundred sample files I
found on the internet. For the most part, it works well. We can now read
compressed files!

I'm sure there are more issues that I haven't come across yet. Please let me
know if you come across a data file that isn't supported and I'll see if I can
add support for the file.

Usage
=====

To install, run:

```
pip install sas7bdat
```

To create a sas7bdat object, simply pass the constructor a file path. The
object is iterable so you can read the contents like this:

```
#!python
from sas7bdat import SAS7BDAT
with SAS7BDAT('foo.sas7bdat', skip_header=True) as reader:
    for row in reader:
        print row
```

Each row will be a list of values of type `string`, `float`, `datetime.date`,
`datetime.datetime`, or `datetime.time`. Without `skip_header`, the first row
returned will be the SAS variable names.

If you'd like to get a pandas DataFrame, use the `to_data_frame` method:

```
#!python
df = reader.to_data_frame()
```

[Variable
attributes](https://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n08fs0rt7fikeln1uh0t8v5pt25d.htm)
are available from `reader.columns`. The order of these columns will be the same
as the corresponding values in each `row`. Each `Column` has the following
attributes:

* `col_id` (`int`) - the column number
* `name` (`bytes`)
* `label` (`bytes`)
* `format` (`str`)
* `type` (`str`)
* `length` (`int`)
            

Raw data

            {
    "_id": null,
    "home_page": "https://bitbucket.org/jaredhobbs/sas7bdat",
    "name": "sas7bdat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "sas,sas7bdat,csv,converter",
    "author": "Jared Hobbs",
    "author_email": "jared@pyhacker.com",
    "download_url": "https://files.pythonhosted.org/packages/4d/7b/d41d280b12c776e67c840bace0e5f02acda6adb13cd1fbb04293ece0bc3c/sas7bdat-2.2.3.tar.gz",
    "platform": "",
    "description": "sas7bdat.py\n===========\n\nThis module will read sas7bdat files using pure Python (2.6+, 3+). No SAS software\nrequired! The module started out as a port of the R script of the same name\nfound here: <https://github.com/BioStatMatt/sas7bdat> but has since been\ncompletely rewritten.\n\nAlso included with this library is a simple command line script,\n`sas7bdat_to_csv`, which converts sas7bdat files to csv files. It will also\nprint out header information and meta data using the `--header` option and it\nwill batch convert files as well. Use the `--help` option for more information.\n\nAs is, I've successfully tested the script almost three hundred sample files I\nfound on the internet. For the most part, it works well. We can now read\ncompressed files!\n\nI'm sure there are more issues that I haven't come across yet. Please let me\nknow if you come across a data file that isn't supported and I'll see if I can\nadd support for the file.\n\nUsage\n=====\n\nTo install, run:\n\n```\npip install sas7bdat\n```\n\nTo create a sas7bdat object, simply pass the constructor a file path. The\nobject is iterable so you can read the contents like this:\n\n```\n#!python\nfrom sas7bdat import SAS7BDAT\nwith SAS7BDAT('foo.sas7bdat', skip_header=True) as reader:\n    for row in reader:\n        print row\n```\n\nEach row will be a list of values of type `string`, `float`, `datetime.date`,\n`datetime.datetime`, or `datetime.time`. Without `skip_header`, the first row\nreturned will be the SAS variable names.\n\nIf you'd like to get a pandas DataFrame, use the `to_data_frame` method:\n\n```\n#!python\ndf = reader.to_data_frame()\n```\n\n[Variable\nattributes](https://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n08fs0rt7fikeln1uh0t8v5pt25d.htm)\nare available from `reader.columns`. The order of these columns will be the same\nas the corresponding values in each `row`. Each `Column` has the following\nattributes:\n\n* `col_id` (`int`) - the column number\n* `name` (`bytes`)\n* `label` (`bytes`)\n* `format` (`str`)\n* `type` (`str`)\n* `length` (`int`)",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A sas7bdat file reader for Python",
    "version": "2.2.3",
    "project_urls": {
        "Homepage": "https://bitbucket.org/jaredhobbs/sas7bdat"
    },
    "split_keywords": [
        "sas",
        "sas7bdat",
        "csv",
        "converter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d7bd41d280b12c776e67c840bace0e5f02acda6adb13cd1fbb04293ece0bc3c",
                "md5": "0f0a6f124ce25ba1e035c083ee7e5aee",
                "sha256": "484c609d962442203c15bc719a638de992a23cd13bc1971a5af6dfb0daf9f797"
            },
            "downloads": -1,
            "filename": "sas7bdat-2.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "0f0a6f124ce25ba1e035c083ee7e5aee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16053,
            "upload_time": "2019-07-15T15:29:53",
            "upload_time_iso_8601": "2019-07-15T15:29:53.504170Z",
            "url": "https://files.pythonhosted.org/packages/4d/7b/d41d280b12c776e67c840bace0e5f02acda6adb13cd1fbb04293ece0bc3c/sas7bdat-2.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-07-15 15:29:53",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "jaredhobbs",
    "bitbucket_project": "sas7bdat",
    "lcname": "sas7bdat"
}
        
Elapsed time: 4.17339s