#!/usr/bin/env python # -*- coding: utf-8 -*- # @Project : Python. # @File : 999_draw_table # @Time : 2022/10/17 下午1:36 # @Author : yuanjie # @WeChat : meutils # @Software : PyCharm # @Description : import streamlit as st import pandas as pd import streamlit.components.v1 as components st.set_page_config(page_icon="🌴", page_title="Tabulator表格", layout="wide") file = st.file_uploader("请上传文件", type=["csv"]) if file is not None: df = pd.read_csv(file, encoding="gbk") def draw_table(df, height, width): columns = df.columns column_selection = [] column_selection.append( """""") table_data = df.to_dict(orient="records") column_setting = [] column_setting.append( """{rowHandle:true, formatter:"handle", headerSort:false, frozen:true, width:30, minWidth:30}""") for y in range(df.shape[1]): column_setting.append( {"title": columns[y], "field": columns[y], "width": 200, "sorter": "string", "hozAlign": "center", "headerFilter": "input", "editor": "input"}) components.html("""