ASCIIOutput, end of file marker
- Steve Rowe
- Site Admin
- Posts: 2464
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
ASCIIOutput, end of file marker
A very quick question, the answer may be a bit longer..
Does anyone know a way to get the end of file marker in an ASCIIOutput produced file from TI to either not be produced or an easy way to clean it out afterwards?
Cheers,
Does anyone know a way to get the end of file marker in an ASCIIOutput produced file from TI to either not be produced or an easy way to clean it out afterwards?
Cheers,
Technical Director
www.infocat.co.uk
www.infocat.co.uk
- Michel Zijlema
- Site Admin
- Posts: 713
- Joined: Wed May 14, 2008 5:22 am
- OLAP Product: TM1, PALO
- Version: both 2.5 and higher
- Excel Version: 2003-2007-2010
- Location: Netherlands
- Contact:
Re: ASCIIOutput, end of file marker
Hi Steve,
If I remember correctly I used a DOS copy with /A swictch for this in the past. In TI:
vCmd = 'cmd /c copy /Y /A ' | VfileA | ' ' | VfileB;
ExecuteCommand(vCmd, 1);
This copies the source file (VfileA) to a destination file (VfileB) stripping of the end-of-file character.
Michel
If I remember correctly I used a DOS copy with /A swictch for this in the past. In TI:
vCmd = 'cmd /c copy /Y /A ' | VfileA | ' ' | VfileB;
ExecuteCommand(vCmd, 1);
This copies the source file (VfileA) to a destination file (VfileB) stripping of the end-of-file character.
Michel
- Steve Rowe
- Site Admin
- Posts: 2464
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: ASCIIOutput, end of file marker
Hi Michael,
Thanks for this but I can't get it to work from TI, probably as I'm being a bit thick...
Should the fileName variables contain the full path to the file or just the file name?
What's the /c for? Does this specify the folder, I can't see any reference to this in any help information.
EDIT nevermind either question.....
I've tested the script via the dos window and whilst I can get a second copy of the file created, the copy still has the end of file marker. So I'm still with no solution, anyone have an idea? Maybe I'll finally look at a perl book....
Cheers,
Thanks for this but I can't get it to work from TI, probably as I'm being a bit thick...
Should the fileName variables contain the full path to the file or just the file name?
What's the /c for? Does this specify the folder, I can't see any reference to this in any help information.
EDIT nevermind either question.....
I've tested the script via the dos window and whilst I can get a second copy of the file created, the copy still has the end of file marker. So I'm still with no solution, anyone have an idea? Maybe I'll finally look at a perl book....
Cheers,
Technical Director
www.infocat.co.uk
www.infocat.co.uk
- Steve Vincent
- Site Admin
- Posts: 1054
- Joined: Mon May 12, 2008 8:33 am
- OLAP Product: TM1
- Version: 10.2.2 FP1
- Excel Version: 2010
- Location: UK
Re: ASCIIOutput, end of file marker
perl will clear it easy enough although i don't have any expertise in that area. Excel will also clean it if you run the following VBA:
Will clear all non-printing characters as well as stripping any extra spaces at the end of a cell.
Code: Select all
Sub CleanData()
Application.ScreenUpdating = False
For Each cell In ActiveSheet.UsedRange
cell.Value = Application.Clean(cell.Value)
cell.Value = Application.Trim(cell.Value)
rCount = cell.Row
StatBar
Next cell
Application.ScreenUpdating = True
Application.StatusBar = "Ready"
MsgBox "Done!"
End Sub
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
- Michel Zijlema
- Site Admin
- Posts: 713
- Joined: Wed May 14, 2008 5:22 am
- OLAP Product: TM1, PALO
- Version: both 2.5 and higher
- Excel Version: 2003-2007-2010
- Location: Netherlands
- Contact:
Re: ASCIIOutput, end of file marker
Hi Steve,Steve Rowe wrote:Hi Michael,
Thanks for this but I can't get it to work from TI, probably as I'm being a bit thick...
Should the fileName variables contain the full path to the file or just the file name?
What's the /c for? Does this specify the folder, I can't see any reference to this in any help information.
EDIT nevermind either question.....
I've tested the script via the dos window and whilst I can get a second copy of the file created, the copy still has the end of file marker.
So I'm still with no solution, anyone have an idea? Maybe I'll finally look at a perl book....
Cheers,
The /c switch is a parameter for the cmd command. The /c argument tells the command processor to open, run the specified command, then close when it's done. In the process that I copied the code from both VfileA and VfileB are file names including full path.
I used this code in a while loop to concatenate a number of files to create a single inputfile for a TI process. When I created this solution I found that /A switch in the copy command prevented the intermediate inclusion of the end-of-file characters in the combined file, but after testing again today I found that the total file still ends with an end-of-file character. So this is not going to help you...
Michel
- Steve Rowe
- Site Admin
- Posts: 2464
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: ASCIIOutput, end of file marker
Well I decided to venture into the world of perl for the first time to do this since I really want to process the files server side, going down the VBA approach would have forced me to read the files across the network. After plenty of googling I got to the following script
which I saved as file called dropeof.pl and saved in the data directory of the server.
I can then call it from TI with
vCmd = 'cmd /c dropeof.pl ' | fileName | ' ' | fileNameFinal;
ExecuteCommand(vCmd, 1);
The first line of perl script should be the path to the perl.exe on the server.
It seems to do exactly what I need except that if SOURCE does not exist I get an empty OUTPUT. I could probably solve this in perl but I'm just going to step over the call to perl in TI if the view for my ASCIIOutput doesn't generate any records.
EDIT - note that the path in fileName and fileNameFinal can not contain spaces
Cheers
Code: Select all
#!C:\Perl64\bin\perl.exe
#first arguement in the call is the source file, second is the destination file
open (SOURCE, $ARGV[0]);
open (OUTPUT, ">$ARGV[1]");
while (<SOURCE>) {
chomp;
$test=substr( $_,0,1);
if ($test ne ''){print OUTPUT "$_\n";}
}
close (SOURCE);
close (OUTPUT);
I can then call it from TI with
vCmd = 'cmd /c dropeof.pl ' | fileName | ' ' | fileNameFinal;
ExecuteCommand(vCmd, 1);
The first line of perl script should be the path to the perl.exe on the server.
It seems to do exactly what I need except that if SOURCE does not exist I get an empty OUTPUT. I could probably solve this in perl but I'm just going to step over the call to perl in TI if the view for my ASCIIOutput doesn't generate any records.
EDIT - note that the path in fileName and fileNameFinal can not contain spaces
Cheers
Technical Director
www.infocat.co.uk
www.infocat.co.uk
-
- MVP
- Posts: 214
- Joined: Tue Nov 11, 2008 11:57 pm
- OLAP Product: TM1, CX
- Version: TM1 7x 8x 9x 10x CX 9.5 10.1
- Excel Version: XP 2003 2007 2010
- Location: Hungary
Re: ASCIIOutput, end of file marker
Hello Steve,
This is exactly the solution what I was looking for.
The only problem that the code does not create the second file for me:(
I would appreciate any idea.
- I have tried both with Strawberry and Active Perl (changed the first line )
- I have placed the dropeof.pl to several places from the DataDirectory to D:\
- I have tried with .cma, .txt, .csv extensions
fileName='d:\file';
fileNameFinal='d:\file2';
vCmd = 'cmd /c dropeof.pl ' | fileName | ' ' | fileNameFinal;
ExecuteCommand(vCmd, 1);
I have tried the d:\dropeof.pl in the code also without success.
Thanks in advance,
Peter
This is exactly the solution what I was looking for.
The only problem that the code does not create the second file for me:(
I would appreciate any idea.
- I have tried both with Strawberry and Active Perl (changed the first line )
- I have placed the dropeof.pl to several places from the DataDirectory to D:\
- I have tried with .cma, .txt, .csv extensions
fileName='d:\file';
fileNameFinal='d:\file2';
vCmd = 'cmd /c dropeof.pl ' | fileName | ' ' | fileNameFinal;
ExecuteCommand(vCmd, 1);
I have tried the d:\dropeof.pl in the code also without success.
Thanks in advance,
Peter
Best Regards,
Peter
Peter
- Steve Rowe
- Site Admin
- Posts: 2464
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: ASCIIOutput, end of file marker
Hi Peter,
Just in case there are any marginal differences this is the exact perl that is in use now though I can't see any obvious differences.
HTH! Not sure if there is too much more I can help, I'm by no means a perl novice even let alone an expert
. Please try though!
Cheers,
Steve
Just in case there are any marginal differences this is the exact perl that is in use now though I can't see any obvious differences.
This is the script that I execute from within the TI (did you see my note about no spaces in the paths?)#!C:\Perl64\bin\perl.exe
#first arguement in the call is the source file, second is the destination file
open (SOURCE, $ARGV[0]);
open (OUTPUT, ">$ARGV[1]");
while (<SOURCE>) {
chomp;
$test=substr( $_,0,1);
if ($test ne ''){print OUTPUT "$_\n";}
}
close (SOURCE);
close (OUTPUT);
The perl.exe states version 5.10.1.1006, copyright 1987-2007, Larry Wall, Binary Build and it is ActivePerlcmd /c D:\TM1Data\Live\LiveData\dropeof.pl D:\Partage\TM1\Fileshare\ArcoleExport\abc.csv D:\Partage\TM1\Fileshare\ArcoleExport\123.csv
HTH! Not sure if there is too much more I can help, I'm by no means a perl novice even let alone an expert

Cheers,
Steve
Technical Director
www.infocat.co.uk
www.infocat.co.uk
-
- MVP
- Posts: 214
- Joined: Tue Nov 11, 2008 11:57 pm
- OLAP Product: TM1, CX
- Version: TM1 7x 8x 9x 10x CX 9.5 10.1
- Excel Version: XP 2003 2007 2010
- Location: Hungary
Re: ASCIIOutput, end of file marker
Hi Steve,
Thanks for the information.
I have installed the perl version which works for you (5.10.1.1006) and modified my code, but unfortunately it does not work for me.
I will let you know if I find the solution.
Regards,
Peter
Thanks for the information.
I have installed the perl version which works for you (5.10.1.1006) and modified my code, but unfortunately it does not work for me.
I will let you know if I find the solution.
Regards,
Peter
Best Regards,
Peter
Peter
- Steve Rowe
- Site Admin
- Posts: 2464
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: ASCIIOutput, end of file marker
Hmmmm
A couple of things.
The fact that you are working in the root of a drive seems to be triggering a memory that I tried this and it didn't work. I could be imagining it though.
Any strange security rights issues??
GL.
Steve
A couple of things.
The fact that you are working in the root of a drive seems to be triggering a memory that I tried this and it didn't work. I could be imagining it though.
Any strange security rights issues??
GL.
Steve
Technical Director
www.infocat.co.uk
www.infocat.co.uk