[英]Add a date column in Azure Data Factory
I am wondering if it is possible to add a date column to each file uploaded.我想知道是否可以为每个上传的文件添加一个日期列。
For example each month a CSV is produced.例如,每个月都会生产一个 CSV。 I am wanted to add for example "December 2020" to each row and then for the next months upload add "January 2021" to every row in the CSV file.例如,我想将“2020 年 12 月”添加到每一行,然后在接下来的几个月将“2021 年 1 月”上传到 CSV 文件的每一行。 Before copying this into a SQL database.在将其复制到 SQL 数据库之前。
eg file name "Latest Rating December 2020" I would want the 'December 2020' as a column and be the same value for all rows.例如,文件名“2020 年 12 月最新评级”我希望将“2020 年 12 月”作为一列,并且所有行的值都相同。 The naming convention will be the same for each months upload.每个月上传的命名约定都相同。
Thanks谢谢
I've created a test to add a column to the csv file.我创建了一个测试来向 csv 文件添加一列。
The result is as follows:结果如下:
We can get file name via Child Items
in Get MetaData activity.我们可以通过 Get MetaData 活动中的Child Items
获取文件名。 The dataset is to the container in ADLS.数据集到 ADLS 中的容器。
Then we can declare a variable FileName
to store the file name via the expression @activity('Get Metadata1').output.childItems[0].name
.然后我们可以通过表达式@activity('Get Metadata1').output.childItems[0].name
声明一个变量FileName
来存储文件名。
3.We can use additional column in Copy activity, and use the expression @concat(split(variables('FileName'),' ')[2],' ',split(variables('FileName'),' ')[3])
to get the value we need. 3.我们可以在复制活动中使用附加列,并使用表达式@concat(split(variables('FileName'),' ')[2],' ',split(variables('FileName'),' ')[3])
来获得我们需要的值。 Note that the single quote contains a space.请注意,单引号包含一个空格。 In the dataset, we need key in a dynamic content @variables('FileName')
to specify which file to be copied.在数据集中,我们需要键入动态内容@variables('FileName')
来指定要复制的文件。 The sink is the same as source in Copy activity.接收器与复制活动中的源相同。
Here I think we also can copy into SQL table directly, when we set the sink to a sql table.这里我想我们也可以直接复制到 SQL 表中,当我们将接收器设置为 sql 表时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.