从表格中删除数据

2024-06-01 14:41:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我必须将表格工作簿中的数据刮到csv文件中。 https://public.tableau.com/views/2020_04_06_COVID19_India/Dashboard_India_Cases?:embed=y&:showVizHome=no&:host_url=https%3A%2F%2Fpublic.tableau.com%2F&:embed_code_version=3&:tabs=no&:toolbar=yes&:animate_transition=yes&:display_static_image=no&:display_spinner=no&:display_overlay=yes&:display_count=yes&publish=yes&:loadOrderID=0

我尝试了以下方法,但没有得到任何结果

main.py

import requests
from bs4 import BeautifulSoup


 r = requests.get("https://public.tableau.com/views/2020_04_06_COVID19_India/Dashboard_India_Cases?:embed=y&:showVizHome=no&:host_url=https%3A%2F%2Fpublic.tableau.com%2F&:embed_code_version=3&:tabs=no&:toolbar=yes&:animate_transition=yes&:display_static_image=no&:display_spinner=no&:display_overlay=yes&:display_count=yes&publish=yes&:loadOrderID=0")

     soup = BeautifulSoup(r.content, "html.parser")

     for td in soup.findAll("table"):

     for a in td.findAll("tr"):
      print(a.find('td'))

Tags: nohttpscomdisplayembedpublicviewsyes
1条回答
网友
1楼 · 发布于 2024-06-01 14:41:13

我制作了this python tableau scraper library来列出工作表并将数据导出到每个工作表的数据框中。例如,下面是您要查找的表:

from tableauscraper import TableauScraper as TS

url = "https://public.tableau.com/views/2020_04_06_COVID19_India/Dashboard_India_Cases"

ts = TS()
ts.loads(url)
dashboard = ts.getDashboard()

for t in dashboard.worksheets:
    #show worksheet name
    print(f"WORKSHEET NAME : {t.name}")
    #show dataframe for this worksheet
    print(t.data)

run this code on repl.it

相关问题 更多 >