:: File:TableGenerator.1.1.cmd
:: Set up the database name
set ProjectName=TableFirst
:: Set up the run folder where the perl script is executing
set RunFolder=D:\perl\sfw\TableGenerator
:: Set up the full path to the Perl script
set PerlScript=%RunFolder%\HtmlTableGenerator.1.0.pl
:: Set up the input folder where the input file residues
set InputFolder=D:\perl\sfw\TableGenerator
:: Set up the full path the MetaFile
set InputMetaFile=%InputFolder%\%ProjectName%.txt
:: Set up the full path to Perl
set PerlBin=C:\Perl\bin\perl.exe
:: Set up the output folder
set FolderOutput=output\
:: Delete first all the generated sql files
del "%FolderOutput%\*.html" /q
:: CREATE THE DIRECTORY IF IT DOES NOT EXIST
mkdir %FolderOutput%
:: Action !!!
%PerlBin% %PerlScript% %InputMetaFile% %FolderOutput%
::debug
pause
explorer %FolderOutput%
:: VersionHistory:
:: 1.0.20101001_213742 --- Yordan Georgiev -- Initial creation. Input meta data parsing and debugging
:: 1.1.20101001_221209 --- Yordan Georgiev --- Print Select All per table with Schema . OK
END ================== HtmlTableGenerator.1.0.cmd
.
START ===== HtmlTableGenerator.1.0.pl
use strict ;
package Test ;
my $FileInput = $ARGV[0] ;
my $FolderOutput = $ARGV [1] ;
my $CsvFileSeparator='\t' ;
my $TokenStart = '
my $TokenStop = '
my $LineStart = '
my $LineStop = '
my $FileOutput = "$FolderOutput/" . 'FileOutput.html' ;
my $StrToWriteStart = '
sub main
{
#read the input metadata file
my @ArrayInputFile = ReadInputMetaDataFile();
#FOREACH LINE OF THE FILE DO SOMETHING
my $OldTableName = '' ;
my $ColList = '' ;
my $StrOutput = '' ;
foreach my $line ( @ArrayInputFile )
{
chop($line ) ;
my @tokens= split( "$CsvFileSeparator" , $line ) ;
$line = '' ;
foreach my $token ( @tokens)
{
$token = GenerateToken ( $token ) ;
$line = $line . $token ;
}
$line = GenerateLine ( $line ) ;
$StrOutput = $StrOutput . $line ;
} #eof foreach line
# END FOREACH LINE
WriteFile ( $FileOutput , $StrOutput ) ;
}
# =========================================== eof sub main
sub ReadInputMetaDataFile
{
#READ ALL ROWS OF A FILE TO ALIST
open (FILEINPUT, "<$FileInput") || print "could not open the \$FileInput $FileInput!\n"; my @arrayInputFile =
close FILEINPUT;
return @arrayInputFile ;
}
# =========================================== eof sub ReadInputMetaDataFile
sub GenerateToken
{
my $token = shift ;
$token = $TokenStart . $token . $TokenStop ;
}
# =========================================== eof sub GenerateToken
sub GenerateLine
{
my $line = shift ;
$line = $LineStart . $line . $LineStop ;
return $line ;
}
# =========================================== eof sub GenerateLine
sub trim
{
$_[0]=~s/^\s+//;
$_[0]=~s/\s+$//;
return $_[0];
}
# =========================================== eof sub trim
sub WriteFile
{
my $FileToWrite = shift ;
my $StrToWrite = shift ;
$StrToWrite = $StrToWriteStart . $StrToWrite . $StrToWriteStop;
#READ ALL ROWS OF A FILE TO ALIST
open ( FILETOWRITE , ">$FileToWrite") ||
print "could not open the \$FileToWrite $FileToWrite !\n";
print FILETOWRITE $StrToWrite ;
close FILETOWRITE ;
}
# =========================================== eof sub trim
# Action !!!
main() ;
1 ;
__END__
# VersionHistory:
# 1.1.20101001_222618 --- Yordan Georgiev --- Generates Select All with full [] column list from Table
END ================== HtmlTableGenerator.1.0.pl
.
START ===== TableFirst.txt
Col11 Col12 Col13 Col14
Col21 Col22 Col23 Col24
Col31 Col32 Col33 Col34
END ================== TableFirst.txt
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!