Azure ML Studio是否支持将Excel文件导入为数据集?

时间:2019-08-02 18:19:55

标签: azure ml-studio

我正在使用Azure ML Studio并尝试将Excel文件上传为数据集。但是,我没有选择它。我想念什么吗?

enter image description here

1 个答案:

答案 0 :(得分:0)

听起来您想在Azure Machine Learning Studio的实验的Execute Python Script模块中读取Excel文件。根据官方文档[Execute Python machine learning scripts in Azure Machine Learning Studio][1],有两种方法可以做到这一点。

  1. 要将Excel文件上传到Azure Blob存储,然后按照Accessing Azure Storage Blobs节使用适用于Python的Azure Blob存储SDK进行阅读。

  2. 请参阅Importing existing Python script modules部分,将Excel文件与其他必需的Python软件包打包为zip文件,然后通过自动提取从zip文件名为Script Bundle的目录中读取它由Azure ML Stodio提供。

作为参考,我将向您显示第二种解决方案的详细步骤,如下所示。

  1. 我准备了一个名为test.xlsx的Excel文件,其内容如下。

    enter image description here

  2. 从其PyPi.org页面下载xlrd软件包文件xlrd-1.2.0-py2.py3-none-any.whl,然后将其压缩文件提取到目录test中,并用{{1 }}到一个压缩文件test.xlsx,如下所示。

    enter image description here

  3. 我将zip文件test.zip作为数据集上传到Azure ML Studio,并使用test.zip模块进行了组装。

    enter image description here

  4. 这是我的示例代码。我尝试将Execute Python Scriptos.getcwd()os.listdir()与日志结合使用,以找到用于读取zip文件中文件的正确路径。

    os.listdir('Script Bundle')

它在import pandas as pd def azureml_main(dataframe1 = None, dataframe2 = None): import os print(os.getcwd()) print(os.listdir()) print(os.listdir('Script Bundle')) import xlrd file = 'Script Bundle/test.xlsx' data = xlrd.open_workbook(file) print([sheet.name for sheet in data.sheets()]) print('Input pandas.DataFrame #1:\r\n\r\n{0}'.format(dataframe1)) return dataframe1, 中起作用,日志如下。

enter image description here

希望有帮助。