write_rda#
- write_rda(path, data, *, file_format='xdr', compression='gzip', encoding='utf-8', format_version=DEFAULT_FORMAT_VERSION, constructor_dict=DEFAULT_CLASS_MAP)[source]#
Write an RDA or RDATA file.
This is a convenience function that wraps conversion and unparsing as it is the common use case.
- Parameters:
path (os.PathLike[Any] | str) – File path to be written.
data (dict[str, Any]) – Python dictionary with data and variable names.
file_format (FileFormat) – File format.
compression (Compression) – Compression.
encoding (Encoding) – Encoding to be used for strings within data.
format_version (int) – File format version.
constructor_dict (ConstructorDict) – Dictionary mapping Python classes to functions converting them to R classes.
- Return type:
None
See also
write_rds(): Similar function that writes an RDS file.Examples
Write a Python dictionary to an RDA file.
>>> import rdata >>> >>> data = {"name": "hello", "values": [1, 2.2, 3.3+4.4j]} >>> rdata.write_rda("test.rda", data)