Hello
I have downloaded the following script from
xmlworks.com. The purpose of this scrip is to convert Intraday data exported from AB(using AFL code provided by Graham ) into a pseudo EOD format for use elsewhere(TA programs that do not support IntraDay format).
//////////==========//////////
use strict;
my $infile = shift;
my $outfile = shift;
my $ticker = shift;
open (IN,$infile) || die "Open IN failed $!";
open (OUT,">$outfile") || die "Open OUT failed $!";
my $month = 1;
my $day = 1;
my $year = 1900;
my ($date,$time,$open,$high,$low,$close,$vol);
while (<IN>) {
chomp;
($ticker,$date,$time,$open,$high,$low,$close,$vol) = split /,/;
if ($month == 2 && $day > 28) {
$month = 3;
$day = 1;
}
$month = '0' . $month if length("$month") < 2;
$day = '0' . $day if length("$day") < 2;
$year = '0' . $year if length("$year") < 2;
$date = "$year$month$day";
print OUT "$ticker,$date,$open,$high,$low,$close,$vol\n";
$day += 1;
if ($day == 31) {
$month += 1;
$day = 1;
if ($month == 13) {
$year += 1;
$month =1;
}
}
}
close IN;
close OUT;
__END__
//////////==========//////////
The problem I am encountering is visible by seeing the data from a file converted using the above script.
TICKER,19000101,Open,High,Low,Close,Volume
3IINFOTECH,19000102,137.6000,138.0000,137.6000,138.0000,136234
3IINFOTECH,19000103,137.5000,137.6000,137.1500,137.1500,40269
The heading row contains a date instead of the heading "date". The date that should have been inserted in the first row of price data has been instead inserted where the heading "date" should have been.
I will be very very grateful if someone can kindly spare some time and help me out with this problem.
Regards
Rakesh