azure - 在 Azure 数据工厂中将 JSON 转换为 CSV

标签 azure azure-data-factory

我在将 JSON 转换为 CSV 时遇到问题。 JSON 看起来像这样:

{
  "Key1": "Value1",
  "Key2": "Value3",
  "Key3": "Value2",
  ...
}

我希望 CSV 采用这种格式:

Key, Value
Key1, Value1
Key2, Value2
Key3, Value3
...

如您所见,键和值存储在列中。是否可以在 Azure 数据工厂的数据流中执行此操作?

最佳答案

您可以使用 Azure 数据工厂数据流 Unpivot 转换来实现它。

请参阅下面的重现详细信息。

输入:

enter image description here

数据流:

  1. 添加并将其连接到 JSON 输入文件。在 JSON 设置下的源选项中,选择文档形式为单个文档

enter image description here

源数据预览:

enter image description here

  • 在源之后添加派生列,以添加具有常量值的虚拟列,以便稍后在逆透视转换中使用它。
  • enter image description here

    派生列数据预览:

    enter image description here

  • 在派生列后添加 Unpivot 转换,以将列转换为行。在“逆透视”设置下

    a) 取消分组依据:选择虚拟列。

    b) 逆透视键:为逆透视列命名(例如:键),输入“字符串”。

    c) 未透视列:为未透视列中的数据指定列名称。

  • enter image description here

    enter image description here

    enter image description here

    逆透视数据预览:

    enter image description here

  • 在 Unpivot 之后添加 Select 转换,以删除虚拟列并仅选择输出所需的列。
  • enter image description here

    选择数据预览:

    enter image description here

  • 在末尾添加sink转换并连接到分隔数据集接收器。在设置中,如果您将文件名选项选择为输出到单个文件,则可以提供接收器文件名。
  • enter image description here

    接收器数据预览:

    enter image description here

    输出:

    enter image description here

    关于azure - 在 Azure 数据工厂中将 JSON 转换为 CSV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70696700/

    相关文章:

    azure - 在两个 Azure CSP 订阅之间迁移 Azure DevOps

    Azure-AKS:使用 Postman 测试启用了 TLS 的 Ingress

    azure - Monotouch 和 Azure 移动服务

    azure - 如何在Azure数据工厂中使用自定义脚本来转换数据?

    node.js - 如何通过Azure创建运行管道API触发管道?

    powershell - 如何使用 powershell 重命名 blob 文件

    Azure Data Lake gen 2 - 更改访问层 - 提前删除费用

    sql-server - Azure 数据工厂上的存储过程失败并显示错误消息 : The length of execution output is over limit (around 1M currently)

    Azure 数据工厂逻辑函数表达式无效

    c# - 从 .net 调用 DocumentDb 存储过程