gpt4 book ai didi

azure - 将数据从 Excel 文件加载到 Azure 数据仓库

转载 作者:行者123 更新时间:2023-12-03 03:06:27 25 4
gpt4 key购买 nike

我已成功将数据从 CSV 加载到 Azure SQL Server 数据仓库,但是我现在有一个 excel 文件作为源,当我尝试将此 excel 文件读入 BLOB CSV 时,它会创建一个包含垃圾字符的文件。任何帮助将不胜感激。

最佳答案

要在数据工厂中处理此问题,您需要使用自定义事件 (DotNotActivity),该事件首先将 Excel 文件转换为 CSV。然后进行下游事件,根据需要处理 CSV 数据集。

自定义事件将需要编写一些处理对话的 C# 类。使用 Office 互操作性库或通过执行类似操作将 Excel 文件视为数据表。

    public static string ToCSV(this DataTable table)
{
var result = new StringBuilder();
for (int i = 0; i < table.Columns.Count; i++)
{
result.Append(table.Columns[i].ColumnName);
result.Append(i == table.Columns.Count - 1 ? "\n" : ",");
}

foreach (DataRow row in table.Rows)
{
for (int i = 0; i < table.Columns.Count; i++)
{
result.Append(row[i].ToString());
result.Append(i == table.Columns.Count - 1 ? "\n" : ",");
}
}
return result.ToString();
}

或者查看其他有关相同问题的问题。例如:

Is there any simple way to convert .xls file to .csv file? (Excel)

就其他 Azure 数据工厂胶水而言,编译的库需要存储在 Blob 存储中,并且实际上由 Azure Batch 服务执行。如果要针对 Azure Data Lake 存储进行身份验证,则需要 Azure AD 服务主体。

查看此 blob 帖子,了解有关创建自定义事件的更多详细信息。

https://www.purplefrogsystems.com/paul/2016/11/creating-azure-data-factory-custom-activities/

这个用于 ADL 身份验证:

https://www.purplefrogsystems.com/paul/2016/12/azure-data-lake-authentication-from-azure-data-factory/

希望这有帮助。

关于azure - 将数据从 Excel 文件加载到 Azure 数据仓库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44109957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com