Page 1 of 1
ASCIIOutput, end of file marker
Posted: Tue Sep 22, 2009 2:13 pm
by Steve Rowe
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,
Re: ASCIIOutput, end of file marker
Posted: Tue Sep 22, 2009 2:25 pm
by Michel Zijlema
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
Re: ASCIIOutput, end of file marker
Posted: Wed Sep 23, 2009 3:34 pm
by Steve Rowe
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.

- eof marker.JPG (48.29 KiB) Viewed 9411 times
So I'm still with no solution, anyone have an idea? Maybe I'll finally look at a perl book....
Cheers,
Re: ASCIIOutput, end of file marker
Posted: Wed Sep 23, 2009 4:28 pm
by Steve Vincent
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:
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
Will clear all non-printing characters as well as stripping any extra spaces at the end of a cell.
Re: ASCIIOutput, end of file marker
Posted: Wed Sep 23, 2009 6:54 pm
by Michel Zijlema
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,
Hi Steve,
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
Re: ASCIIOutput, end of file marker
Posted: Thu Sep 24, 2009 1:54 pm
by Steve Rowe
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
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);
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
Re: ASCIIOutput, end of file marker
Posted: Tue Jun 15, 2010 6:37 am
by kpk
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
Re: ASCIIOutput, end of file marker
Posted: Thu Jun 17, 2010 6:49 pm
by Steve Rowe
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.
#!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);
This is the script that I execute from within the TI (did you see my note about no spaces in the paths?)
cmd /c D:\TM1Data\Live\LiveData\dropeof.pl D:\Partage\TM1\Fileshare\ArcoleExport\abc.csv D:\Partage\TM1\Fileshare\ArcoleExport\123.csv
The perl.exe states version 5.10.1.1006, copyright 1987-2007, Larry Wall, Binary Build and it is ActivePerl
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
Re: ASCIIOutput, end of file marker
Posted: Fri Jun 18, 2010 6:31 am
by kpk
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
Re: ASCIIOutput, end of file marker
Posted: Fri Jun 18, 2010 6:08 pm
by Steve Rowe
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