首页 > 解决方案 > Alteryx 无法从数据框写入 SQL/excel

问题描述

我创建了一个 Alteryx 工作流程,在其中运行代码在 python 笔记本中从 Web API 中提取数据,将 API 提取的输出存储为数据帧,并尝试通过锚 1 将其写入 excel 文件。当我收到以下错误时我运行了工作流程:

FileNotFoundError:缓存数据不可用 - 运行工作流以使输入数据在 Jupyter 笔记本 (.\Alteryx_Automation\dsd_runner\jupyterPipes.json) 中可用

我对 Alteryx 很陌生,如果有任何指导/建议,我将不胜感激

Here is code that replicates the error and has similar structure to what I have in my notebook

``from ayx import Alteryx
class DataExtract():
    def __init__(self):
        self.url = 'https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv'
        self.data = dict()
def get_data(self):
    self.data['owid'] = pd.read_csv(self.url)

de = DataExtract()
de.get_data()
temp = de.data['owid']
Alteryx.write(temp,1)``

标签: alteryx

解决方案


解决了这个问题,我在 python 笔记本中发出了一个 os.chdir() 命令,我的工作目录被更改为我没有写权限的目录。通过跟踪当前目录( orig_dir = os.getcwd() )然后在脚本末尾发出 os.chdir(orig_dir) 来解决它。此外,制作类属性的深层副本也有助于解决问题。


推荐阅读