File: plot_example.py

package info (click to toggle)
python-rdata 0.11.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 740 kB
  • sloc: python: 2,388; makefile: 22
file content (24 lines) | stat: -rw-r--r-- 609 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# fmt: off
"""
R data loading
==============

Use the file uploader to convert files to Python.
"""

# sphinx_gallery_thumbnail_path = '_static/R_logo.svg'

from ipywidgets import FileUpload, interact

import rdata


@interact(files=FileUpload(accept="*.rd*", multiple=True))
def convert_from_file(files):
    """Open a rds or rdata file and display its contents as Python objects."""
    for f in files:
        parsed = rdata.parser.parse_data(f.content)
        converted = rdata.conversion.convert(parsed)
        for key, value in converted.items():
            print(f"{key}:")
            print(value)