Page 1 of 1

Read Folder Name Using TI

Posted: Wed Jan 04, 2012 1:31 am
by mariatjahjadi
Dear All,

I am developing TM1 and using TI as ETL tools.

Could someone tell me how to read folder name using TI?

I need to access a file inside the folder, and need to determine who is the owner of the file based on the folder name.

I can do it with SSIS, but have no clue how to do that using TI.

Thanks.

Re: Read Folder Name Using TI

Posted: Wed Jan 04, 2012 9:57 am
by Duncan P
I am a little confused here. How is it that the file is being specified if not by a path?
If there is a path then it will be possible to crack it open using the SCAN and SUBST rule functions that also work in TI.

Re: Read Folder Name Using TI

Posted: Wed Jan 04, 2012 10:49 am
by rmackenzie
Often, with TM1, you just have to write something yourself:

Code: Select all

sPath='c:\test\this\folder name\whatever.txt';

# get the string between the last and second last \
nCounter=LONG(sPath);
nContinue=1;
nFoundFirstBackslash=0;
sFolderName='';
WHILE(nContinue=1&nCounter>0);
  sChar=SUBST(sPath,nCounter,1);
  IF(nFoundFirstBackslash=1&sChar@<>'\');
    sFolderName=sChar|sFolderName;
  ENDIF;
  IF(sChar@='\');
    IF(nFoundFirstBackSlash=1);
      nContinue=0;
    ELSE;
      nFoundFirstBackSlash=1;
    ENDIF;
  ENDIF;
  nCounter=nCounter-1;
END;

# test parse output
AsciiOutput('test_parse.txt',sFolderName);