简体   繁体   English

如何为 Python GUI 创建一个按钮,以通过选择 a.csv 的 .sh 文件将数据加载到 Cassandra

[英]How to create a button for Python GUI to load data into Cassandra via .sh file choosing a .csv

With this.sh I can load a.csv file into Apache Cassandra using DSBulk loader:使用 this.sh,我可以使用 DSBulk 加载器将 a.csv 文件加载到 Apache Cassandra 中:

export PATH=/home/workstation/dsbulk-1.7.0/bin:$PATH

source ~/.bashrc

dsbulk load -url /home/workstation/ll/datatest.csv -k test_keyspace -t test_data  -delim "," -header false 

Using the.sh showed, I'm creating a Python GUI to load the.csv data with a button.使用.sh 显示,我正在创建一个 Python GUI 以使用按钮加载.csv 数据。 So, I've implemented the code below.所以,我已经实现了下面的代码。 I can load data with that button, but, how can I choose the.csv file which must be opened and loaded?我可以使用该按钮加载数据,但是,如何选择必须打开和加载的.csv 文件? I used a similar function in a different way but not to choose a file opened from the.sh.我以不同的方式使用了类似的 function 但没有选择从 .sh 打开的文件。

This is the function of the button:这是按钮的function:

def Dataloader():
   
   subprocess.call('./tester.sh', shell=True)


button = Button(window, text=" Load data into APC ", bg="black", fg="white",command=Dataloader)

Some suggestion?有什么建议吗? Where am I going wrong?我哪里错了?

Thank you谢谢

Solution:解决方案:

on the.sh must be written在.sh上必须写

echo "you selected $(zenity --file-selection)"

then, the action needed es: dsbulk....然后,需要执行的操作 es: dsbulk....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不使用pandas / numby或matplotlib的情况下将csv文件加载到python GUI中以创建地图 - How to load csv file into python GUI to create a map without using pandas/numby or matplotlib cron启动的.sh不会通过python创建文件 - .sh started by cron does not create file via python 如何创建用python创建的数据的csv文件 - How to create a csv file of data created in python 如何使用python脚本将没有标题的csv数据加载到cassandra列族中 - how to load csv data without header into cassandra column family using python script 如何将CSV文件中的数据加载到Python脚本中以进行概率分析? - How to load data in CSV file into Python script for probability analysis? 如何在 python 中加载具有不常见结构的 csv 文件以最终旋转数据? - How to load a csv file with uncommon structure in python to eventually pivot the data? 使用 Python 将 .csv 文件加载到 Apache Cassandra 中的问题 - Problem to load .csv files into Apache Cassandra with Python 如何通过Python将文本文件中存储的数据加载到PostgreSQL数据库中 - How to load data stored in a text file into a PostgreSQL database via Python python将dict数据加载到csv文件 - python load dict data to csv file 如何从python中的数据创建.csv或.xlsx文件 - How to create .csv or .xlsx file from a data in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM