Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
khaycock
Creator
Creator

Trim Field Name

I have a data set that I am unable to link up to a date apart from with the file name. The file name in this case is named SHIP_Night_Week2.xls for each week etc. I need to change it to just 2 so need to trim either sides and all of the text from it. Is that possible?

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Kathryn,

Here is a method.

=TextBetween('SHIP_Night_Week2.xls','Week','.xls')

View solution in original post

8 Replies
beck_bakytbek
Master
Master

Hi Kathryn,

could you give more information or screenshot, what do you expect to achieve?

Beck

tamilarasu
Champion
Champion

Hi Kathryn,

Here is a method.

=TextBetween('SHIP_Night_Week2.xls','Week','.xls')

tamilarasu
Champion
Champion

Or

=Replace(SubField('SHIP_Night_Week1212.xls','Week',2),'.xls','')

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Or this one:

=KeepChar('SHIP_Night_Week965123.xls','0123456789') & '.xls'

khaycock
Creator
Creator
Author

How can I use this in the script to load for each file? As currently SHIP_Night_Week is loaded in as a wildcard with many different weeks?

Peter_Cammaert
Partner - Champion III
Partner - Champion III

I'm not sure I understand.

If you mean that you want a link field to some other WeekNr field, just create it during your load. Like in:

LOAD ...

     KeepChar(FileName(), '0123456789') AS WeekNumber,

     ...

FROM [*.xls] (options);

khaycock
Creator
Creator
Author

How can I use this in the script to load for each file? As currently SHIP_Night_Week is loaded in as a wildcard with many different weeks?

tamilarasu
Champion
Champion

In that case, you can try something like

Load *,

Textbetween(FileName(),'Week','xls') as Filename

From

....


OR

Load *,

Replace(SubField(FileName(),'Week',2),'.xls','') as Filename

From

....