Hi All,
I have a TI process which has a data source as "File1.csv" file. I have a requirement to use other file say "File2.csv" in the same TI process.
I Google it and searched to get some function to get this approach. Is there any TM1 function which can import a file within a TI process.
Thanks
TM1 function to import a text file
-
- MVP
- Posts: 2836
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: TM1 function to import a text file
If the question is can you have one file for the data source and in that same process open up another file, as a second data source, and pull values from the second file into the TI as well then the answer is no.
-
- MVP
- Posts: 3241
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.1.5
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: TM1 function to import a text file
As Tom said, no.
You could for instance make a second process with File2.csv as the source.
The TI process reads the file and sets up a cube (or similar) to hold the contents of the file or do other manipulations.
Then execute the existing process using the cube as a way to pull data.
You could for instance make a second process with File2.csv as the source.
The TI process reads the file and sets up a cube (or similar) to hold the contents of the file or do other manipulations.
Then execute the existing process using the cube as a way to pull data.
Best regards,
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
-
- MVP
- Posts: 1831
- Joined: Mon Dec 05, 2011 11:51 am
- OLAP Product: Cognos TM1
- Version: PA2.0 and most of the old ones
- Excel Version: All of em
- Location: Manchester, United Kingdom
- Contact:
Re: TM1 function to import a text file
If the files are in the same format and the TI is to do the same thing to them you can recursively call the TI from itself and use the datasource functions to change the file it looks at (just make sure to add a stop into the recursion.)
Or do a join on the files if possible and query them instead of reading as an ascii source.
Or do a join on the files if possible and query them instead of reading as an ascii source.
Declan Rodger
-
- MVP
- Posts: 600
- Joined: Wed Aug 17, 2011 1:19 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2
- Excel Version: 2003 2007
- Location: York, UK
Re: TM1 function to import a text file
It you want to import File2 for use in Proc1 then in what form do you expect it to be available within Proc1? If you just want the file as a raw string then it is possible to write a TI to do that.
If you just want to process File2 during the execution of Proc1 but don't need the results directly in Proc1 then just use ExecuteProcess to call Proc2.
If File1 and File2 are of the same structure and you want to process them in turn then, within a process (called e.g. OuterProc), have an outer process that uses WildcardFileSearch to iterate over "File*.csv" and pass the names you get back to e.g. InnerProc as a parameter. InnerProc should set the name as its datasource and process as normal. This is a little cleaner than recursion for large numbers of files and and leaves you less exposed to stack size limits in the TI execution engine.
If you just want to process File2 during the execution of Proc1 but don't need the results directly in Proc1 then just use ExecuteProcess to call Proc2.
If File1 and File2 are of the same structure and you want to process them in turn then, within a process (called e.g. OuterProc), have an outer process that uses WildcardFileSearch to iterate over "File*.csv" and pass the names you get back to e.g. InnerProc as a parameter. InnerProc should set the name as its datasource and process as normal. This is a little cleaner than recursion for large numbers of files and and leaves you less exposed to stack size limits in the TI execution engine.
-
- Community Contributor
- Posts: 128
- Joined: Wed Oct 14, 2009 7:46 am
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 11
- Location: London
Re: TM1 function to import a text file
Just thought I'd add my 2 cents:
If you want to make a TI process dynamic in terms of what file it uses as a data source, set up your process with "File1.csv" as the data source and create a text parameter on the Parameters tab (e.g. psFileName). This will be populated as "File1.csv" or "File2.csv" as appropriate at run-time by whichever way you want to initiate your process (chore, wrapper TI process, command line, Java).
Then put something like the below in your Prolog tab so it's executed before the data source is opened:
This assumes your .csv files are located in a folder in the same directory as the logging directory, but you can change it as necessary.
Dan
If you want to make a TI process dynamic in terms of what file it uses as a data source, set up your process with "File1.csv" as the data source and create a text parameter on the Parameters tab (e.g. psFileName). This will be populated as "File1.csv" or "File2.csv" as appropriate at run-time by whichever way you want to initiate your process (chore, wrapper TI process, command line, Java).
Then put something like the below in your Prolog tab so it's executed before the data source is opened:
Code: Select all
# Obtain TM1 instance directory information
# =================================
vsLogPath = GetProcessErrorFileDirectory;
vsTM1ParentPath = DELET( vsLogPath, SCAN( 'tm1logfiles\', vsLogPath), 12);
# Set data source
# =============
vsDataSource = vsTM1ParentPath | 'filestoimport\' | psFileName;
DatasourceNameForServer = vsDataSource;
Dan