Forum Discussion
Transform Sample File: Add Column>Custom Column to add "File Name"
- 3 years ago
Hi ryan1919
Here is an alternative solution. You need to create a "Transform Sample File" function manually instead of using the function & queries generated automatically by Combining binary column [Content].
First connect to a CSV file using Text/CSV connector. Treat it as a sample file and transform it per your need. For example, below is my sample query Jan (sample file).
Duplicate the sample query, then modify its code like below. I convert this query into a custom function with two parameters FileName and FolderPath. These paramters are used to connect to a CSV file and FileName is used to add a custom column which displays the file name.
Then connect to the folder using Folder connector. On the Source step, remove other columns except [Name] and [Folder Path]. Invoke the custom function created earlier to add a column. Use [Name] and [Folder Path] to provide values for the parameters.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi ryan1919
I'm afraid this is difficult to achieve. In the current "Transform Sample File" query, you will see the first Source step is Source = Csv.Document(Parameter1,[Delimiter=",", Columns=29, Encoding=65001, QuoteStyle=QuoteStyle.Csv]), it gets data from a parameter Parameter1. If you go to check the current value of the parameter, you will see its value is a binary value which comes from the [Content] column. The [Content] column contains the data inside the file while the file name is a meta data outside of [Content] value. The file name is in the [Name] column next to [Content]. To meet your requirement, we need to bring [Name] into the binary value in [Content], then it may be possible to be read into "Transform Sample File". However, I think this is not easy. Personally I'm not sure if this is possible currently.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi ryan1919
Here is an alternative solution. You need to create a "Transform Sample File" function manually instead of using the function & queries generated automatically by Combining binary column [Content].
First connect to a CSV file using Text/CSV connector. Treat it as a sample file and transform it per your need. For example, below is my sample query Jan (sample file).
Duplicate the sample query, then modify its code like below. I convert this query into a custom function with two parameters FileName and FolderPath. These paramters are used to connect to a CSV file and FileName is used to add a custom column which displays the file name.
Then connect to the folder using Folder connector. On the Source step, remove other columns except [Name] and [Folder Path]. Invoke the custom function created earlier to add a column. Use [Name] and [Folder Path] to provide values for the parameters.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.