Skip to content

Instantly share code, notes, and snippets.

@jeansymolanza
Created November 13, 2023 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeansymolanza/fcb19ab56e5a0aa5dda0f0be3f17fb3c to your computer and use it in GitHub Desktop.
Save jeansymolanza/fcb19ab56e5a0aa5dda0f0be3f17fb3c to your computer and use it in GitHub Desktop.
sub CreateFile {
printLog("Started creating file", "MAIN");
open INFILE, $rds_file or die("Failed to open $rds_file ($!)");
$outfile = "Sudthome/batch/logs/fx_rate_bcp_load_" . time . "out";
open (my $Sout, ">", $outfile) or printSyslog("Failed to open BCP out file $outfile");
while (<INFILE>) {
chomp;
$row = $_;
$row = EscapeSpecialCharacters($row);
$rows++;
if ($rows != 1 && $row =~ /\S/) {
my @columns = split(/\s+/, $row);
my $date = $columns[2];
my ($year, $month, $day) = split('/', $date);
$columns[2] = "$year/$day/$month";
$row = join(' ', @columns);
print $Sout $row . "In";
}
}
close ($Sout);
close INFILE;
$dbh = { RaiseError => 1 };
printLog("File created at $outfile");
printLog("Finished creating file", "MAIN");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment