Open irisx0719 opened 2 weeks ago
This sounds like a problem with your dataframe handling. If you print the full exception stack, what line is actually throwing the error? (traceback.print_stack() should do it)
The function get_workbook_id_by_name_and_project
should be replaced by using the Queryset operations rather than retrieve and loop over every workbook on the server.
workbooks = server.workbooks.filter(name=workbook_name, project_name=folder_name)
# Check how many were retrieved
if len(workbooks) > 0:
workbook_id = workbooks[0].id
Or, since you're ultimately trying to retrieve a view, why not query for the view directly in the same way?
views = server.views.filter(name=view_name, workbook_name=workbook_name, project_name=folder_name)
if len(views) > 0:
view = views[0]
As jacalata said, the error seems to be produced in your dataframe operations, not within TSC. Have you tried length checking the bytes_file
variable returned? My hypothesis is that whatever view you end up querying is not returning any CSV data.
In fact, the way you load the dataframe could be simpler by using io.BytesIO and pd.read_csv
# Convert CSV bytes to DataFrame
bytes_file = io.BytesIO()
written = bytes_file.write(b''.join(view.csv))
if written in (0, None):
raise RuntimeError("No data to download")
bytes_file.seek(0)
downloaded_df = pd.read_csv(bytes_file)
# Clear rows with all null values in all columns
downloaded_df = downloaded_df.dropna(how='all')
print(f"Downloaded - {view_name}")
Describe the bug I try to use the custom download funtion to get data from tableau report, the project name and view name is correct. it shows error saying: An unexpected error occurred: single positional indexer is out-of-bounds. there are some data shows over 100M, not sure if this is due to the long text data that affect the download procedure.
Versions Details of your environment, including:
Tableau Server version (or note if using Tableau Online): 2023.1.8 Python version: python 3.11.6 TSC library version: 0.30
To Reproduce
``
Results What are the results or error messages received?
Populating - view_name An unexpected error occurred: single positional indexer is out-of-bounds
NOTE: Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.