-
Notifications
You must be signed in to change notification settings - Fork 17
/
import.pl
32 lines (24 loc) · 1.27 KB
/
import.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
$dir = "./import";
@resolutions = ("1", "5", "10", "15", "30", "60");
foreach $resolution (@resolutions){
print "*** READING $resolution BARS ***\n";
opendir($dh, $dir);
@files = grep { /^*_$resolution.csv$/ } readdir($dh);
close($dh);
foreach $file (@files){
print "File: $file\n";
system(qq~ mysql -pSSmxynk,. -u root autoStock -e "load data local infile '$dir/$file' into table stockHistoricalPrices fields terminated by ',' lines terminated by '\\n' ignore 1 lines (symbol, \@test, priceOpen, priceHigh, priceLow, priceClose, sizeVolume) set dateTime = str_to_date(\@test, '\%d-\%b-\%Y \%k:\%i'), resolution = '$resolution', exchange='NYSE';" ~);
}
}
print "*** READING DAILY BARS ***\n"; #^[^"]*$
opendir($dh, $dir);
@files = grep { /^*.csv$/ } readdir($dh);
close($dh);
foreach $file (@files){
if ($file =~ /^((?!_[1635]).)*$/){
print "Importing: $file\n";
system(qq~ mysql -pSSmxynk,. -u root autoStock -e "load data local infile '$dir/$file' into table stockHistoricalPrices fields terminated by ',' lines terminated by '\\n' ignore 1 lines (symbol, \@test, priceOpen, priceHigh, priceLow, priceClose, sizeVolume) set dateTime = str_to_date(\@test, '\%d-\%b-\%Y \%k:\%i'), resolution = '1440', exchange='NYSE';" ~);
}
}
print "Done!";