python - 创建并选择同一个工作表
问题描述
在我的代码中 gspread 创建了一个新的统计工作表,名称为“Year__Month_Day_HourMinute_'XTeam'_vs'Yteam'”,我这样做是为了更容易找到合适的工作表。如何选择此表以供进一步使用。由于这个小程序将同时用于2-3场比赛(yay small time Ultimate frisbee)。任何想法?
我不能做一个简单的“worksheet = sh.sheet1”,因为我不知道# 会是什么。我的解决方案是省略名称的分钟,这样会更容易,只需将名称创建者代码部分复制粘贴到选择代码部分,但我希望会有更好的解决方案。
on_press: root.worksheet = root.np.add_worksheet(title=str(root.localtime.year) + "_" + str(root.localtime.month) + "_" + str(root.localtime.day) + "_" + str(root.localtime.hour) + str(root.localtime.minute) + spinner1_id.text + "_vs_" + spinner2_id.text, rows ="100", cols= "20")
解决方案
I would not recommend using a title that varies like that, as you have to dig all that data back up just to form a search for it. I would use only 3 Varying points in your title at most, such as 'DATE_xTEAM_yTEAM'. DATE would be a STRING value such as "042318" where you can split each element from the string (MONTHDAYYEAR).
This is a method I would personally do for accessing the data easier: Manifest a JSON file which includes a DICTIONARY of all the spreadsheets (titles) ever created. The KEY would be a NUMBER (1) and the value would be the title. So if you wanted to find the second game in the season, create a small python script that (using 'import json') would find the value for that key. Basically a dictionary is the best way to organize the titles.
-Ryan
推荐阅读
- omnet++ - 如何在inet项目中实现RSU应用
- mysql - SQL 约束:检查双向引用的表是否具有共同值
- javascript - HTML / JS 表格 - 根据输入数字计算
- javascript - 当发出命令的用户对以下选项之一做出反应时,如何让机器人编辑自己发送的消息?
- java - Java中的大写单词
- javascript - 从滑块的进度条中取消链接 mat-slider thumb 标签值
- scala - 合成语法树和变量树以避免跨阶段评估
- flutter - Flutter/Dart 从 Firestore 投射到地图中
- sql - 为什么我在 vba 代码中使用 SQL 会收到错误消息?
- google-bigquery - 如何将存储在 GG Bigquery 中的数据文件导出到 GZ 文件夹中?