Skip to main content

RDS Format

Description​

RDS (.rds) is R's native binary format for saving a single R object. It's commonly used in R statistical computing to save individual data frames, vectors, lists, or other R objects. Unlike RData which can save multiple objects, RDS saves exactly one object. This implementation supports reading RDS files and converting them to Python dictionaries.

File Extensions​

  • .rds - RDS files

Implementation Details​

Reading​

The RDS implementation:

  • Uses pyreadr library for reading
  • Reads RDS files which contain a single R object
  • Converts data frames to pandas DataFrames, then to dictionaries
  • Requires file path (not stream)

Writing​

Writing is not currently supported for RDS format.

Key Features​

  • Single object: Contains exactly one R object
  • Statistical format: Designed for R statistical computing
  • Totals support: Can count total rows
  • Type preservation: Maintains data types from R
  • Efficient: More efficient than RData for single objects

Usage​

from iterable import open_iterable

# Basic reading
with open_iterable('data.rds') as source:
for row in source:
print(row)

Parameters​

No specific parameters required.

Limitations​

  1. Read-only: RDS format does not support writing
  2. pyreadr dependency: Requires pyreadr package
  3. File path required: Requires filename, not stream
  4. Flat data only: Only supports tabular data (data frames)
  5. Memory usage: Entire file is loaded into memory
  6. Single object: File must contain a single object (typically a data frame)

Compression Support​

RDS files can be compressed with all supported codecs:

  • GZip (.rds.gz)
  • BZip2 (.rds.bz2)
  • LZMA (.rds.xz)
  • LZ4 (.rds.lz4)
  • ZIP (.rds.zip)
  • Brotli (.rds.br)
  • ZStandard (.rds.zst)

Use Cases​

  • Statistical analysis: Working with R data files
  • Data migration: Converting R data to other formats
  • Research data: Processing research datasets in R format
  • Academic research: Common in academic research and data science
  • Single object storage: Saving and loading individual R objects

Error Handling​

  • Missing dependency: optional libraries raise ImportError with an install hint (pip install 'iterabledata[<extra>]' when an extra exists).
  • Read-only: opening with mode="w" raises WriteNotSupportedError or ValueError.
  • Bad or unsupported input: may raise ValueError, OSError, or library-specific errors.
  • See Troubleshooting for decoding, detection, and engine issues.
  • RData - R's multiple object format
  • SAS - SAS statistical format
  • Stata - Stata statistical format
  • SPSS - SPSS statistical format
  • CSV - Simple text format for conversion