Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
evansabres
Specialist
Specialist

FileName Function

Hello -

I am using a loop script for my application that appears as such:

DIRECTORY 'Q:\qlkvw\prod\data\digital\social';

FOR EACH vFileName in FILELIST ('Q:\qlkvw\prod\data\digital\social\*.csv')

FROM [$(vFileName)] (txt, codepage is 1252, embedded labels, delimiter is ',', msq);
NEXT vFileName

I have an inline table that has a list of accounts, which I have the filed called taSCREENNME

Each File appears in this manner (from the data warehouse) YYYY-MM-aggr-SAB-xxxxxx, and there are 12 other thee letter variations

I want to extract the SAB (and the other three letter variations)  from the filename and rename as taSCREENME to link the tables.

Is this possible within the script?

Thank you.

5 Replies
sunny_talwar

Is it always three dash away from the left? If that's true, you can use Subfield function here

SubField(taSCREENNME, '-',4) & '-' & SubField(taSCREENNME, '-', 5) as taSCREENNME

evansabres
Specialist
Specialist
Author

taSCREENNME is a field that I created in my in-line table. I need to re-create the FileName to match a part of the in-line table field.

sunny_talwar

Can you share some of the file names so that we can see the format they follow?

evansabres
Specialist
Specialist
Author

[ taID, taAccount, taSCREENNME

1, @account, SAB

2, @anotheracct, BIL

3, @accountthree, BAN];

sunny_talwar

This seems like expected output, right? How does the raw data looks like Evan?