Create a derived column based on a value within the file name
I am importing a CSV file which is easy enough, but I have an issue where I need to manufacture a couple of column values based on the filename of the input. So this same process will import different types of records to the same table in sql server.
I need to pull out the record code from the file name.
For instance, say I can use the same package to input two different CSV files. One is named Input_M02_Data.csv and one named Input_B15_Data.csv. I need to create a derrived column and store the record code there (i.e.: M02 or B15) based
on which file it came out of.
fyi-
I also need to create a second column for Dept based off of the file name as well. M02 is dept 45 and B15 is dept 99 which I also need to insert into this table when I import the data from the .csv file.
Any help is greatly appreciated!
Hi Jason,
According to your description, you want to add two derived columns based on the file name to also insert into table. One stores the value between two “_” within file name, another stores the department based on that column.
If in this scenario, we can add a variable FileName that stores the filename, then add the two variables as derived columns like below in the Derived Column Transformation:
Name:
SUBSTRING(@[User::FileName],FINDSTRING(@[User::FileName],"_",1)+1,FINDSTRING(@[User::FileName],"_",2)-(FINDSTRING(@[User::FileName],"_",1)+1))
Dept:
@[User::Name] =="M02"?"dept 45":@[User::Name] =="B15"?"dept 99":"dept 00"
The following screenshot is for your reference:
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
If you have any feedback on our support, please click
here.
Katherine Xiong
TechNet Community Support
Similar Messages
-
How can I add form field value to the file name in save as dialog box
I do not want the form to be saved automatically, just want the form to auto populate the "file name" only.
A little background on the forms I want to use: My company has 70 retail outlets, I'll use one of our pdf forms called an "Incident Report" as an example. I would like for a store manager to be able to complete the form, then email the form to the main office (I already have javascript to add field values and form name to the email subject line), once the main office receives it, I want for them to be able to file the pdf electronically on our server. We have mutliple forms that we use so I do not want any of the forms to automatically save anywhere, (at this time anyway) I just want the office personnel to be able to click "save as" (or whatever they will need to click) and the form automatically add certain field values from the pdf they have received, of which will be different each time the form is sent to the office (Date, store #, employee name etc.) in addition to the name of the form in the "File name" of the "Save As" dialog box. The main office employees will decide into which server file the pdf should be saved.
I'm using Acrobat 8 professional, the stores and office personnel use Adobe reader.
One little note: We currently print and file a lot of paper on a daily bases, as soon as I can get this to work, we are going green.
Me and a lot of trees in this will really apprecitate any help you can give with this! :-)You might want to take a look at the document "Developing Acrobat Applications Using JavaScript" (js_developer_guide.pdf) which is part of the Adobe Acrobat SDK, which can be downloaded here. Read the "Privileged versus non-privileged context" (p. 45ff.). You will find an example for "Executing privileged methods in a non-privileged context". Should be almost exactly what you are looking for.
Small Outline: For security reasons ("the user always has to know what's going on") you are not allowed to use the "Doc.saveAs"-method without the user permission (--> in a non-privileged context). In order to reach the goal of a privileged context you can use a trusted function. You do this by creating a JavaScript file (*.js) in either the Application-JavaScript-Folder (default location on Windows systems: "%ProgramFiles%\Adobe\Acrobat 10.0\Acrobat\Javascripts") or the User-JavaScript-Folder (default location on Windows systems: "%AppData%\Adobe\Acrobat\10.0\JavaScripts"). Add the following content to the new file:
myTrustedBrowseForDoc = app.trustedFunction( function ( oArgs ) {
app.beginPriv();
var myTrustedRetn = app.browseForDoc( oArgs );
app.endPriv();
return myTrustedRetn;
myTrustedSaveAs = app.trustedFunction( function ( doc, oArgs ) {
app.beginPriv();
var myTrustedRetn = doc.saveAs( oArgs );
app.endPriv();
return myTrustedRetn;
The developer guide actually wants you to add this content to the existing "config.js" file. I recommend creating a new file, since its easier to deploy in a network. Either way, every client/user who needs to be able to save documents this way, needs this JavaScript Code in his Application/User-JavaScript-Folder.
Within the Acrobat Document, which you want to obtain a certain file name, you can now use the trusted functions "myTrustedBrowseForDoc" and "myTrustedSaveAs" to store the file. To call the trusted functions and deliver the file name you can either you use a form field (button) or you add a new menu item. Add the following JavaScript Action to the button/menu item and change "Roller Coaster" to the name of the field which contains the value which you want to become the new file name:
var fileName = this.getField("Roller Coaster").valueAsString;
try {
var oRetn = myTrustedBrowseForDoc({bSave: true, cFilenameInit: fileName + ".pdf"});
try {
myTrustedSaveAs(this, { cPath: oRetn.cPath, cFS:oRetn.cFS });
catch(e) {
console.println("Save not allowed, perhaps readonly.");
catch(e) {
console.println("User cancelled Save As dialog box");
Good Luck! -
Merging of flat files based on some value in the file.
Hi all,
I have one requirment in which I need to pick some flat files(Let say N number of files).
Third row in each file, needs to be read and all files having same value in 3rd row needs to be merged in single file.
There should be as many output files as many different values at row 3rd in all files.
All the files having unique 3rd row value, will be having sequence number in 4th row. While merging we need to take care of the sequence number and need to be merged based on sequence number.
All the files need to be placed at some FTP location
Thanks
Jaithanks for ur response Raj.
My input files don't have any fixed length or structure.. So It is not possible to write FCC.
Can you please explain your point in detais
My approach is to store the files at some intermediate location and go with two interfaces.
If you have any other idea please let me know.
Thanks
Jai -
Can you assign field values as the file name
When filling fillable pdf forms I would like to assign the name of the file (automate a Save As) to field values.
Place a regular button on the form and write the below code in the click event of button:
app.execMenuItem("SaveAs");
Thanks,
Vipin -
How to create Dynamic field so it appears the file name
Hi,
I was wondering if anyone knows how to create a dynamic text field so it automatically appears the file name created of the document.
thanks alot !!!
Jack
[email protected]Hi, Seems we can't upload examples anymore, but here is a screen shot of what I meant.
Hope it helps -
Dispaly or Hide a column based on Prompt Value
Hi All,
How can I Display or Hide a Column based on Prompt Value selected?
On my dashboard I have a Report/Request and a Dashboard Prompt.
Dashboard Prompt has three values, say: *'A', 'B' and 'C'*.
And my report/request has three columns named *'Field1', 'Field2'* and Field3'.
What I am trying to achieve is that whenever user selects prompt values as *'A' or 'B'* all the three fields on my report named *'Field1', 'Field2' and Field3'* should be displayed, however whenever user selects prompt values as *'C'* only fields named *'Field1' and 'Field2'* should be displayed.
Thanks,
DeepakHi Bhavna,
I tried using View Selector, however I am not able to achieve the required functionality with that.
I created a Request with 3 columns in it, then I switched to criteria and added another table to that. The new table automatically got the similar 3 columns used in the first report. Now when I tried to delete one of those columns from the new report, it also got deleted from the first report.
All the views are dependent, changes made to one are reflected in other.
Can't figure it out, where am I going wrong?
Thanks,
Deepak -
HTML Dataset - how to filter based on data values within columns
I have had success with using the XML dataset and filtering based on user input (see javascript example below)
<script type="text/javascript">
var ds2 = new Spry.Data.XMLDataSet("disciplinary_actions3.xml", "doh/disciplinary_actions2[type='<? echo($type) ?>'][name>='<? echo($name) ?>']");
ds2.setColumnType("date-of-sanction", "date");
</script>
The XML dataset filters the results based on the type and name values within the XML dataset columns.
I need to accomplish this type of filtering with an HTML table. All that I have been able to accomplish with the use of the in the rowselector (see example below)
<script type="text/javascript">
<!-- the setRowSelector filters by the class attribute on the row in the html table
var ds4 = new Spry.Data.HTMLDataSet("disciplinary_physicians_htmldataset.php", "physician-list");
ds4.setRowSelector("tr.<? echo($type) ?>");
ds4.loadData();
//-->
</script>
How can I filter the HTML dataset based on the data VALUES within the table columns and NOT the class or id or span or div,,,etc?
Although my advanced dataselector within Dreamweaver CS4 has a column selector... I can't under or get it to work.
Any assistance or direction is greatly appreciated.Hi Ron,
According to your description, you want to pass the Terminal number that user logon to where clause without needing to create a userid table, right?
As per my understanding, you need to add an additional table to store the user and corresponding terminal, so that you can filter the data to show the rows based on the user and corresponding terminal. Here are some blogs which describe dynamic security
on tabular model, please see:
http://blogs.msdn.com/b/himanshu1/archive/2013/03/02/implementing-dynamic-security-in-tabular-models.aspx
http://www.bidn.com/blogs/ChrisSchmidt/ssas/4332/dynamic-security-in-tabular
If this is not what you want, there is no other approach to pass the Terminal number that user logon to where clause without needing to create a userid table. Thank you for your understanding.
Regards,
Charlie Liao
TechNet Community Support -
Looping multiple excel files at a time in ssis and create a new column to insert the files names
Hi Friend,
i have one requirement.
I got around 200 excel files with date as file name like 120101.xls, 120102.xls (YYMMDD).
I am able to loop all the files and insert data but i am unable to load the files names using ssis.
Please can any one help to fix this using script task or any other code..
It is very urgentThank You Vaibhav,
I want to insert the file name along with the other columns of data from excel.
like this deriving a new column FILE_NAME
Your ForEach Loop task must be returning the entire file path, I suppose.
1. Get the file name from your file path.
New variable: FileName
Expression : RIGHT(@[User::FilePath],FINDSTRING(REVERSE(@[User::FilePath]),"\\",1)-1)
2. Inside Data flow, after Excel source use Dervied Column and use above @FileName
3. At your OLEDB destinition, use MyFileName.
-Vaibhav Chaudhari -
How do I grab a value from a file name and load it in a field/column?
Hi,
I am loading this .txt file (OUS_RAW_NYC_05_2011.txt) into an internal table i_raw.
I want to pick out the NYC characters from the file name and fill it as value for <wa_raw>-field1 for all records.
How do I do this?
Pls advice.
Thanks!Hi Durgesh,
I am doing this in a program via SE38 and not via transformation routine.
Now I am working on this piece of code to get the value.
file_str = //rdmsbw/dev/data/output/all/OUS_RAW_HCM_05_2011.txt
I only want the characters HCM from file_str.
When I execute this code below:
MOVE file_str TO org_unit.
WRITE / org_unit+37(12).
<wa_raw>-/BIC/ZOUORGUT = org_unit.
my output is = //rdm
how do i extract out HCM?
Pls advice.
PS: also pls help me out with my another post
http://forums.sdn.sap.com/thread.jspa?threadID=2141618&tstart=0 -
Import From Folder: How to Extract the File Name in a Custom Column.
Hello All
Here´s what we´re trying to do:
We have a folder with csv files named like this:
Sales_2013-02-05.csv
Sales_2013-02-04.csv
Sales_2013-02-03.csv
Sales_2013-02-02.csv
Sales_2013-02-01.csv
And in the csv files there are the sales columns but not the date column.
So we want to extract the date from the file name.
I´ve tried entering = Source[Name] in a custom column, but it adds a "LIST" link, and on a click on expand, it adds ALL file names from the folder in each row, instead of just the needed one.
If we could get the proper file name in each row (from where they got extracted), we could split the column and get the date from there. But I don´t know how put the filename there properly.
Can you help?This isn't entirely straightforward, but it's definitely possible. What you need to do is to apply all of your transforms to each individual file instead of the combined files. I do that as follows:
1) Use Folder.Files as generated by the GUI to look at the list of my files.
2) Pick one file and do all the transformations to it that I want to apply to all of the files. Sometimes, this just amounts to letting the autodetection figure out the column names and types.
3) Go into the advanced editor and edit my code so that the transformations from step 2 are applied to all files. This involves creating a new function and then applying that function to the content in each row.
4) Expand the tables created in step 3.
As an example, I have some files with names that match the ones you suggested. After steps 1 + 2, my query looks like the following:
let
Source = Folder.Files("d:\testdata\files"),
#"d:\testdata\files\_Sales_2013-02-01 csv" = Source{[#"Folder Path"="d:\testdata\files\",Name="Sales_2013-02-01.csv"]}[Content],
#"Imported CSV" = Csv.Document(#"d:\testdata\files\_Sales_2013-02-01 csv",null,",",null,1252),
#"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
#"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
in
#"Changed Type"
For step 3, I need to take steps 3-5 of my query and convert them into a function. As a check, I can apply that function to the same file that I chose in step 2. The result looks like this:
let
Source = Folder.Files("d:\testdata\files"),
Loader = (file) =>
let
#"Imported CSV" = Csv.Document(file,null,",",null,1252),
#"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
#"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
in
#"Changed Type",
#"d:\testdata\files\_Sales_2013-02-01 csv" = Source{[#"Folder Path"="d:\testdata\files\",Name="Sales_2013-02-01.csv"]}[Content],
Loaded = Loader(#"d:\testdata\files\_Sales_2013-02-01 csv")
in
Loaded
Now I apply the same function to all of the rows, transforming the existing "Content" column into a new value:
let
Source = Folder.Files("d:\testdata\files"),
Loader = (file) =>
let
#"Imported CSV" = Csv.Document(file,null,",",null,1252),
#"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
#"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
in
#"Changed Type",
Transformed = Table.TransformColumns(Source, {"Content", Loader})
in
Transformed
Finally, I need to expand out the columns in the table, which I can do by clicking on the expand icon next to the Content column header. The resulting query looks like this:
let
Source = Folder.Files("d:\testdata\files"),
Loader = (file) =>
let
#"Imported CSV" = Csv.Document(file,null,",",null,1252),
#"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
#"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
in
#"Changed Type",
Transformed = Table.TransformColumns(Source, {"Content", Loader}),
#"Expand Content" = Table.ExpandTableColumn(Transformed, "Content", {"One", "Two", "Three"}, {"Content.One", "Content.Two", "Content.Three"})
in
#"Expand Content"
From here, you should be able to get to what you want. -
How do I get a new value for the service name field and update it in Connection Properties?
I am running Windows Vista. I just upgraded to Firefox 4. When I try to log on to the internet, it tells me the proxy server is refusing connections. A diagnostic reported Error 815 and said the remote server is not responding because there is an invalid value for the "Service Name" field. It said to get a new value and update it in Connection Properties. How do I do this?
When you create a new film script, the first page you see is a title page.
The page after this title page is the one where you generally type in your scenes.
It looks like you are facing some issue and not able to delete any text.
Can you please send me this script so that I can have a better look at your issue?
You can save this script to disk by using option 'File -> Save to disk'. This will create a '.stdoc' file on your system.
Just mail this '.stdoc' file to me at 'roverma <at> adobe <dot> com'
Thanks -
Selecting a list of files and creating a list of only the file names?
Hopefully this is an easy question, one that I can't seem to figure out. I have a folder of photos and I would like to select all their file names and create a text list of just the file names. Every time I try I select the photos themselves and when pasted into my text document all of a sudden I have a lot of images. Any advice on how to do this? Thanks Jeff
You're part way there. Do this in TextEdit. Open a new document, CMDSHIFTT to put it into plain text format, paste in the contents of your photo folder, and be surprised when only the names get pasted and not the images. If you want them in alphabetical order, change the photo folders view to list and click on the name column before copying.
-
SSIS - creating part of the file name from an id in the database
I am trying to figure out how to pull an "id" from my data source to include in the file name. Right now the file name created looks like customer_002_timestamp.txt. I need to add the id to the file name and I need to grab it at the time I get
the data, so then the file name becomes customer_002_id_timestamp.txt.
My data source is Oracle and I am using Attunity, so I do not have the capability of using the resultset found in the SQL Task because I have to use the data task.
Has anyone ever extracted an id from a query against Oracle using the Attunity connector to add as part of the file name? If so, how would I add that to my control flow task?
Thanks in advance for any assistance.Is it a static id value you want
Then you can just use a SSIS variable to hold value from resultset in execute sql task
Then inside your data flow you can use an expression for setting value of another variable which can be used for setting filename in your destination task. The expression will include logic to concatenate id variable also which we populated in the previous
step.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
It's very annoying to have to delete half of the file name each time. Is there a way to just have it pop out as whatever you want to title it and the file extension?
In Compressor 3 - Create a custom destination, where you want to save the compressed files.
Once it is created, click on the custom destination and look in the Inspector - you will see the Output Filename Template for the destination. Delete the "- Setting Name" so that it just says "Source Media Name".
Now apply this destination to your clips to be compressed.
In Compressor 4, I believe the default is just the file name, but you can modify it in the same way by using the inspector for your custom destination when you create a custom destination.
MtD -
Setting Dynamic values to the payload-name / Content Desc
Hi All,
I am using a PayloadZIp module and i am trying to zip the file and retain the filename.
For this i have done the following things. I have used PayloadZIp in the Sender channel. In the recv channel used the DynamicConfigurationBean and wrote the value as a part of message_interface and then using variable substitution i have configured made the filename as the sender name.zip
for eg if the file zipped at the sender side is name1.txt the recv channel would be name1.txt.zip where the variable substituiton would have the value name1.txt
but the problem is that the value of the file inside the zip is not name1,txt . I would like it to be name1.txt
I have used the messageTransformBean and stuff tried setting the ContentTypes Desc all of them take constant values. i am not able to set the real filename as the filename for the attachment.
Can anyone share their views on this and let meknow hw i can achieve this
Rgds
adityaHi
> I am using a PayloadZIp module and i am trying to zip the file and retain the filename.
> For this i have done the following things. I have used PayloadZIp in the Sender channel.
If you are trying to zip a file, then why are you using the PayloadZipbean on the Sender CC, you should use the module on the Receiver CC.
> for eg if the file zipped at the sender side is name1.txt the recv channel would be name1.txt.zip where the variable substituiton would have the value name1.txt
>
> but the problem is that the value of the file inside the zip is not name1,txt . I would like it to be name1.txt
>
What file name are you getting now?
have a look at this blog : http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417700%29ID0591392850DB01436613452367233705End?blog=/pub/wlg/5899
Pooja.
Maybe you are looking for
-
App Store version won't open. When I click on the icon, I get the following pop-up. "Warning. The Library in "Users/me/Pictures/aperture library.aplibrary" cannot be upgraded" and then an option to quit. So the App does not even launch. I deleted and
-
I'm trying to tidy up my itunes playlists and it would be helpful to be able to separate out all the items that AREN'T in any playlist. I can do this by looking at files individually, but it would be good to be able to list them all out or sort them
-
Is there an update for N93 ?
Did Nokia release an update for N93 ? I have V20.20.0.58
-
Hello, I have a virtual machine set up with OEL4 and Oracle Database 9iR2 installed on it quite a while back. All had worked well at the time of setup. Couple of days back, I decided to update the OS and ran "yum update" with yum pointing to "el4_lat
-
After updating to 10.9.1 keyboard toast
After updating to 10.9.1, the keyboard attached to my mac mini is misbehaving. Many letters don't function and some letters continue to repeat after being pressed. I am unable to log in to my account because I cannot type the password properly. Th