Skip to main content

Squishes data into rows and columns

Project description

Rolumns

Rolumns is a Python package for squishing data into rows and columns.

Installation

Rolumns requires Python 3.7 or later.

pip install rolumns

Examples

Say we have this data that we want to transform into a table with "Name" and "Email" columns:

{
    "name": "Robert Pringles",
    "email": "bob@pringles.pop"
}

We'll start by creating and adding our columns to a rolumns.Columns instance.

The first argument of add is the name and the second is the value key:

import rolumns

data = {
    "name": "Robert Pringles",
    "email": "bob@pringles.pop",
}

columns = rolumns.Columns()
columns.add("Name", "name")
columns.add("Email", "email")

To create a list of rows that make up a table, we pass those columns into a rolumns.renderers.RowsRenderer instance then call render:

renderer = rolumns.renderers.RowsRenderer(columns)
rows = renderer.render(data)

This creates an iterable list of lists that can be passed into something like openpyxl to emit an Excel spreadsheet:

[
    ["Name",            "Email"],
    ["Robert Pringles", "bob@pringles.pop"],
]

You can also render to Markdown via the rolumns.renderers.MarkdownRenderer:

renderer = rolumns.renderers.MarkdownRenderer(columns)
markdown = renderer.render(data)
Name Email
Robert Pringles bob@pringles.pop

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

rolumns-0.1.4-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page