经历了一场灾难, 我需要将位于excel列(“G7”、“G8”)两行中的两个数据导出到google工作表的两列中。我该怎么做
import gspread
from gspread_dataframe import get_as_dataframe, set_with_dataframe
from oauth2client.service_account import ServiceAccountCredentials
import pyperclip
import pyautogui as p
import rpa as r
import pandas as pd
import tabula
import openpyxl
r.init()
r.url('https://www.meudetran.ms.gov.br/veiculo.php#')
p.sleep(2)
janela = p.getActiveWindow()
janela.maximize()
p.sleep(2)
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open_by_key('1AGYhinoPiE9xUABnrNEfVGjLf5s_bAJGjpz9hatfIQU')
worksheet = wks.get_worksheet(0)
dados = get_as_dataframe(worksheet)
df = pd.DataFrame.from_records(dados, columns=["Placa", "Renavam"])
set_with_dataframe(worksheet, df)
df2 = get_as_dataframe(worksheet)
for row in df2.itertuples():
df = tabula.read_pdf(text, pages=1)[1]
df.to_excel('dados.xlsx')
wb = openpyxl.load_workbook('dados.xlsx')
sheet = wb.active
venc = sheet['G8'].value
valor = sheet['G7'].value
worksheet.update(row[3], venc)
最后一行不会更新google表单的第3列
我相信你的目标和现状如下
修改点:
当上述各点反映到脚本中时,它将变成如下所示
修改的脚本:
在这个修改后的脚本中,我在脚本中修改了以下
gc = gspread.authorize(credentials)
df = tabula.read_pdf(text, pages=1)[1]
可以正常工作。请小心这个李>valor, venc
都会附加到列“C”和“D”中李>参考文献:
相关问题 更多 >
编程相关推荐