Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

FILE TITLE AS FIELD VALUE

Hello Commnunity,

I want to do somtething a bit special.

I have this as files :

the file name contain the year of the data, but in the excel table itself the year field doesnt exist.

I want to know if its possible to extract that year from the file name et create a year field directly in the script.

Thanks

1 Solution

Accepted Solutions
alexandros17
Partner - Champion III
Partner - Champion III

Yes, when you load the instruction FileName() returns the name of the file , so

Load

....

....

Right(filename(),4) as Year

....

Resident

....

View solution in original post

7 Replies
SreeniJD
Specialist
Specialist

Hi There,

Create a seperate table by loading all files with a loop and store the titles as field names in that table then join this with applymap.

Hope this help

Sreeni

Not applicable
Author

Hi Jd Sreeni,

Can you give me an example (maybe the script) pleasE?

Thnaks

swuehl
MVP
MVP

Try something like

LOAD

     TextBetween(FileBaseName(), '-','.') as Year,

     ...

FROM Excel-2009.xls

...;

alexandros17
Partner - Champion III
Partner - Champion III

Yes, when you load the instruction FileName() returns the name of the file , so

Load

....

....

Right(filename(),4) as Year

....

Resident

....

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Year you can use FileName() Function to extract the File Name and use Subfield function to extract the part that you need.

Example

Tab1:

LOAD

...... ,

......,

FileName()               AS File_Name

,Subfield(FileName(),'-',2)          AS File_Year

FROM

......SourceFile.xls;

Not applicable
Author

include -->   Date#(LEFT(right(Filename(),8),4),'YYYY') as Year   in your Load Statement

You can include some functions in the load, like this:

Load *, filename() as Filename, Date#(LEFT(right(Filename(),8),4),'YYYY') as Year

From 12015.txt (TXT);

Not applicable
Author

please close the thread by marking the correct answer / helpful answers