如何解决将Googlesheet数据上传到Google Cloud服务,然后使用CloudSQL进行分析
请有人建议-我对各种选择感到困惑。
我参与了多个地点的慈善活动。它提供低成本的药品。当前的交易数据-销售交易存储在基于存储的Googlesheets中。随着它的发展,一个一个地分析变得很痛苦。 数据是结构化的。每个表/标签都有定义的字段。
我想做的是:
- 将每个位置的每日数据上传到GoogleCloud(或类似物)中。我希望这种情况在每天晚上从每个位置的午夜自动发出。
- 使用Cloud SQL数据库来分析此数据-整体上按位置,逐项等进行分析-例如-列出每个位置的项A的所有交易的清单-或它们的摘要。 / li>
我一直在使用Google表格查询,并喜欢使用Importrange将所有数据集中到一个地方,但是现在数据量太高了。我需要存储和分析全年的数据。
现在的问题
- 以上工具明智吗?还是有更好(更轻松)的解决方案?
- 如何进行设置-如何自动将每个位置的每日数据放入Google Cloud
我对Google表格和GAS感到满意。也可以适应SQL类型查询。
解决方法
"""Import these modules"""
import gspread
from oauth2client.service_account import ServiceAccountCredentials
"""Import the sheet"""
scope = [
'https://www.googleapis.com/auth/spreadsheets','https://www.googleapis.com/auth/drive'
]
creds = ServiceAccountCredentials.from_json_keyfile_name("Path to your
credentials.json",scope)
client = gspread.authorize(creds)
sheet = client.open("Your sheet").sheet1
"""The cell on Top of a column is for the title of the column """
sheet.updatecell(1,1,"Sales")
"""Reading the file where the data is stored and writing it in the sheet"""
with open("Path to the file where the sales are stored","r") as l:
data = l.readlines()
for e,i in enumerate(data):
i = i[:-1]
sheet.updatecell(len(e+2),i)
我希望这会有所帮助,因为我不知道数据的存储和组织方式,所以我无法做更多的事情。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。