Skip to main content

Xfilios

Excel and Docx FileIO handlers in the client side for Streamlit (in future Dash will also be considered) Framework. The library provides easy to use classes to encode or decode Docx and Excel at the client side. The following core features are available in the library:

  • Convert an uploaded Docx-file into base64 encoded string to send over HTTP post request (a wrapper over python-docx package)
  • Convert Data received from an HTTP get/post request into Downloadable Excel file (a wrapper over pandas and openpyxl)
  • Combine multiple data source into multi-sheet Downloadable Excel file at the frontend (a wrapper using pandas ReadExcel function with openpyxl)

This package is actually a wrapper over pandas and python-docx package. It is possible to extend other fileIO types like csv, text etc in further release.

DocxHandler

When a Docx file is uploaded into streamlit, it consider the content as a file like object. The package xfilios provide a class called DocxHandler which has a class method can receive a file like object and will return a DocxHandler object. After create a handler object it easy to convert the content into base64 encoded string to send it over a Rest API as follows:

import streamlit as st
from xfilios.docx import DocxHandler

def docx_handler_demo():
    st.title('Demo of xfilios DocxHandler')
    content = st.file_uploader("Upload Docx File", type="docx")
    if content:
        handler = DocxHandler.from_file_like(content)
        # Now you can send the encoded string over Http post request
        document_base_64 = handler.to_base64_str()
        # requests.post(body={"data": document_base_64})
        st.text("Here is the base64 encoded document {}...".format(document_base_64[:10]))

        # Or if you received a base64 encoded binary document you can create a downloadable link
        download_link = handler.create_download_link(filename="demo.docx")
        download_text = f"Please Download the document back {download_link}"
        st.markdown(download_text, unsafe_allow_html=True)

image info

TableHandler and ExcelHandler The TableHandler and ExcelHandler can work together to achieve the same functionality like DocxHandler. After you upload a Excel file you can use TableHandler to collect the content of the file. If you have multiple table you can load all the tables and wrap them with TableHandler and create a list of TableHandler and hand it over to ExcelHandler. ExcelHandler will finally create a downloadable Excel file where each table will an Excel sheet.

import streamlit as st
from xfilios.table import TableHandler
from xfilios.excel import ExcelHandler

def excel_handler_demo():
    st.title('Demo of xfilios ExcelHandler')
    content = st.file_uploader("Upload Docx File", type="xlsx")
    if content:
        # Each table handler will consist one table
        table_handler = TableHandler.from_file_like(content)
        # You can put multiple table handler into a list [table_handler1, table_handler2 ...]
        excel_handlers = ExcelHandler([table_handler])
        download_link = excel_handlers.create_download_link(filename="demo.xlsx")
        download_text = f"Please Download the File back {download_link}"
        st.markdown(download_text, unsafe_allow_html=True)
        st.markdown("Here is the content of the file")
        st.table(table_handler.get_data_as_dataframe())

image info

Metadata

Release files for xfilios 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xfilios 0.0.4
File Size Uploaded Provenance Actions
xfilios-0.0.4.tar.gz 8.7 kB Without provenance Details for xfilios-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xfilios 0.0.4
File Interpreter ABI Platform Actions
xfilios-0.0.4-py3-none-any.whl Python 3 none any Details for xfilios-0.0.4-py3-none-any.whl

Total release size: 17.1 kB

Release files / xfilios-0.0.4.tar.gz

Download URL xfilios-0.0.4.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1e9d9f23b7c8bbb29c8b2cc7ef5ebd6136c0b1bc3007aee0824d46a02fa2f86c
BLAKE2b-256 checksum
How to use checksums
9b587e2ffffe3a6bba071454e0a95e1b83c2a42fbe077fc27c1b0b47f936c79e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / xfilios-0.0.4-py3-none-any.whl

Download URL xfilios-0.0.4-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51aa434a262f92a7827cc2c97df166038b08bedb33ca3321fbe20ef9bc1e8ba9
BLAKE2b-256 checksum
How to use checksums
69b3543f9c9fad4678b08215b2e395ffac10da76eaa6fa40dfd6d0453392d00c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Security for xfilios 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page