如何在Azure数据工厂中将单行添加到csv文件中? [英] How to prepend a single line to a csv file in Azure Data Factory?

查看:53
本文介绍了如何在Azure数据工厂中将单行添加到csv文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure Blob存储中有一个csv/txt文件,格式为:

<身体>
第1列第2列 Column3
数据数据数据

在文本文件中,它看起来像:

Column1,Column2,Column3等

数据,数据,数据等

我正在尝试在ADF中添加一行作为文件的第一行,以使其看起来像这样:

BATCH IMPORT,IMPORT 1.0(此行中包含逗号)

Column1,Column2,Column3等

数据,数据,数据等

我尝试使用合并文件,更改了定界符,但似乎无法使其起作用.在此行之前,无需处理数据.添加该行后,我将使用二进制复制活动将其发送到其目的地.在不使用外部功能(例如Azure功能或批处理服务)的情况下,是否可以在ADF中实现此目标?

感谢您的提前帮助.

如果可能的话,我也很乐意与此一起使用Azure Functions?

解决方案

我们可以使用

  • 然后在 source1 处,我们连接到源csv.

  • 在源数据集中选择无定界符.数据预览如下:

  • 添加另一个headers.txt源,其中包含单行 BATCH IMPORT,IMPORT 1.0 .

  • 同样,在数据集中选择 No delimiter .数据预览如下:

  • Union1 活动中的
  • Union header source1 数据预览如下:

  • 然后我们可以沉入csv

  • I have a csv/txt file in Azure Blob Storage of the form:

    Column1 Column2 Column3
    data data data

    In the text file it looks like:

    Column1, Column2, Column3, etc.

    data, data, data, etc.

    I am attempting to prepend a single line in ADF as the first line in the file so that it looks like:

    BATCH IMPORT, IMPORT 1.0 (the comma is included in this line)

    Column1, Column2, Column3, etc.

    data, data, data, etc.

    I have attempted to use merge files, changed the delimiting around but can't seem to make it work. There is no need to work with the data after this line has been prepended. I will be using a binary copy activity to send it to its destination once the line has been added. Is there any way to achieve this in ADF without using external sources like Azure Functions or Batch Services?

    Thanks for helping in advance.

    Edit: I would also be happy to work with Azure Functions for this as well if that is possible?

    解决方案

    We can use data flow in ADF to achieve that.

    1. We can add a csv or text file contains the header BATCH IMPORT, IMPORT 1.0 to Azure Blob Storage.

    2. Then at source1 we connect to the source csv.

    3. Select No delimiter at source dataset. Data preview is as follows:

    4. Add another source of headers.txt, which contains the single line BATCH IMPORT, IMPORT 1.0 .

    5. The same, select No delimiter at the dataset. Data preview is as follows:

    6. Union header and source1 at Union1 activity Data preview is as follows:

    7. Then we can sink to a csv

    这篇关于如何在Azure数据工厂中将单行添加到csv文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆