A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://rdata.readthedocs.io/en/latest/modules/rdata.parser.parse_file.html below:

parse_file — rdata 1.0.1.dev0 documentation

parse_file#
parse_file(file_or_path, *, expand_altrep=True, altrep_constructor_dict=DEFAULT_ALTREP_MAP, extension=None)[source]#

Parse a R file (.rda or .rdata).

Parameters:
  • file_or_path (BinaryFileLike | BinaryBufferFileLike | PathLike[Any] | Traversable | str) – File in the R serialization format.

  • expand_altrep (bool) – Whether to translate ALTREPs to normal objects.

  • altrep_constructor_dict (Mapping[bytes, Callable[[RObject], tuple[RObjectInfo, Any]]]) – Dictionary mapping each ALTREP to its constructor.

  • extension (str | None) – Extension of the file.

Returns:

Data contained in the file (versions and object).

Return type:

RData

See also

parse_data(): Similar function that receives the data directly.

Examples

Parse one of the included examples, containing a vector

>>> import rdata
>>>
>>> parsed = rdata.parser.parse_file(
...              rdata.TESTDATA_PATH / "test_vector.rda")
>>> parsed
RData(versions=RVersions(format=2,
                         serialized=196610,
                         minimum=131840),
      extra=RExtraInfo(encoding=None),
      object=RObject(info=RObjectInfo(type=<RObjectType.LIST: 2>,
                     object=False,
                     attributes=False,
                     tag=True,
                     gp=0,
                     reference=0),
      value=(RObject(info=RObjectInfo(type=<RObjectType.REAL: 14>,
                                      object=False,
                                      attributes=False,
                                      tag=False,
                                      gp=0,
                                      reference=0),
                     value=array([1., 2., 3.]),
                     attributes=None,
                     tag=None,
                     referenced_object=None),
             RObject(info=RObjectInfo(type=<RObjectType.NILVALUE: 254>,
                                      object=False,
                                      attributes=False,
                                      tag=False,
                                      gp=0,
                                      reference=0),
                     value=None,
                     attributes=None,
                     tag=None,
                     referenced_object=None)),
             attributes=None,
             tag=RObject(info=RObjectInfo(type=<RObjectType.SYM: 1>,
                                          object=False,
                                          attributes=False,
                                          tag=False,
                                          gp=0,
                                          reference=0),
                         value=RObject(info=RObjectInfo(type=<RObjectType.CHAR: 9>,
                                                        object=False,
                                                        attributes=False,
                                                        tag=False,
                                                        gp=64,
                                                        reference=0),
                                       value=b'test_vector',
                                       attributes=None,
                                       tag=None,
                                       referenced_object=None),
                         attributes=None,
                         tag=None,
                         referenced_object=None),
             referenced_object=None))

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