Skip to content

Unable to retrieve file extension of workbook prior to calling workbooks.download method #312

@kevinshrugged

Description

@kevinshrugged

Thanks for helping out. I'm a little new to this whole thing, but I seem to be stuck in a catch 22 situation.

I am trying to download all workbooks/datasources from the server. Given whether the workbook or datasource has an embedded extract, the resulting file will either be twbx or twb (tdsx and tds for datasources). If I call the workbooks.download method, the file will automatically download with the correct extension.

The problem however is that I need to sanitize the filenames to remove symbols that are not supported by the underlying OS in filenames. I can specify the 'filepath' parameter of workbooks.download with an ".twbx" extension to force it to accept the sanitized name, which brings me back to the issue where I cannot determine if a workbook is twbx or twb without calling workbooks.download.

workbooks.download also truncates the filename automatically if it cannot write the full name, e.g. if a workbook is named "A/B testing" it will truncate the name to "B testing". This causes some issues for workbooks that have similar suffixes that end up being overwritten.

Does anyone know a way around this? If I could get the extension prior to calling the workbooks.download method, I could hard code the filepath to use the sanitized name. Obviously I can download everything once then read the extensions from there, but that seems like a crazy waste of resources.

Example:

Allows me to force sanitized name, but I have to specify extension:
workbook_filepath = server.workbooks.download(workbook.id, filepath=workbook_project_folder+'\\'+workbook_name+'.twbx', no_extract=False)

Automatically downloads with correct extension, but does not use sanitized name:
workbook_filepath = server.workbooks.download(workbook.id, filepath=workbook_project_folder, no_extract=False)

Thank you again, really appreciate any input into this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions