Read SAS files stored as either XPORT or SAS7BDAT format files.
String, path object (implementing os.PathLike[str]
), or file-like object implementing a binary read()
function. The string could be a URL. Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is expected. A local file could be: file://localhost/path/to/table.sas7bdat
.
If None, file format is inferred from file extension. If âxportâ or âsas7bdatâ, uses the corresponding format.
Identifier of column that should be used as index of the DataFrame.
Encoding for text data. If None, text data are stored as raw bytes.
Read file chunksize lines at a time, returns iterator.
If True, returns an iterator for reading the file incrementally.
For on-the-fly decompression of on-disk data. If âinferâ and âfilepath_or_bufferâ is path-like, then detect compression from the following extensions: â.gzâ, â.bz2â, â.zipâ, â.xzâ, â.zstâ, â.tarâ, â.tar.gzâ, â.tar.xzâ or â.tar.bz2â (otherwise no compression). If using âzipâ or âtarâ, the ZIP file must contain only one data file to be read in. Set to None
for no decompression. Can also be a dict with key 'method'
set to one of {'zip'
, 'gzip'
, 'bz2'
, 'zstd'
, 'xz'
, 'tar'
} and other key-value pairs are forwarded to zipfile.ZipFile
, gzip.GzipFile
, bz2.BZ2File
, zstandard.ZstdDecompressor
, lzma.LZMAFile
or tarfile.TarFile
, respectively. As an example, the following could be passed for Zstandard decompression using a custom compression dictionary: compression={'method': 'zstd', 'dict_data': my_compression_dict}
.
Added in version 1.5.0: Added support for .tar files.
DataFrame if iterator=False and chunksize=None, else SAS7BDATReader or XportReader, file format is inferred from file extension.
See also
read_csv
Read a comma-separated values (csv) file into a pandas DataFrame.
read_excel
Read an Excel file into a pandas DataFrame.
read_spss
Read an SPSS file into a pandas DataFrame.
read_orc
Load an ORC object into a pandas DataFrame.
read_feather
Load a feather-format object into a pandas DataFrame.
Examples
>>> df = pd.read_sas("sas_data.sas7bdat")
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4