我已经使用python自动刷新了Tableau打包的工作簿(.twbx),方法是解压缩.twbx文件,用刷新的数据源替换数据,然后重新压缩为.twbx。此文件需要在Tableau Reader中打开;但是,当我尝试这样做时,会收到一条错误消息,说明无法打开文件:
请注意,下面的代码不包含任何实际更新读取器文件数据源的语言。我只是想看看我是否可以解压和重新压缩文件,然后在Reader中成功打开
我的解压/再解压代码如下:
#zip the 3 files to create the TWBX file (TWB, TDE and a logo image file)
z = zipfile.ZipFile(dir+"/"+"1"+tableau_twbx_file, "w")
z.write(tableau_twb_template_file)
z.write(r"C:\filepath\TEST.twb Files\Data\Extracts\Test Data.hyper")
z.close()
filename = r"C:\filepath\1TEST.twbx"
os.rename(filename, filename[:-4] + 'zip')
from zipfile import ZipFile
with ZipFile(r"C:\filepath\1TEST.zip", 'r') as zipObj:
# Extract all the contents of zip file in current directory
zipObj.extractall()
filename = r"C:\filepath\1TEST.zip"
os.rename(filename, filename[:-3] + 'twbx')
目前没有回答
相关问题 更多 >
编程相关推荐