#!c:/xampp/perl/bin/perl use strict; use warnings; use DBI; use dbConnect_nursing; sub printVariables(@_) { foreach my $variable (@_) { print $variable . "\n"; } print "###############################################\n"; } sub processLine { my @temp; chomp($_[0]); unshift(@temp, $_[0]); my $var = shift(@temp); return $var; } ################################### connect to the database ############################################ # data source name my $dsn = "DBI:$dbConnect::db_platform:$dbConnect::db_database:$dbConnect::db_host:$dbConnect::db_port"; # perl DBI connect my $connect = DBI->connect($dsn, $dbConnect::db_user, $dbConnect::db_pw, {'RaiseError' => 1}); ################################### connect to the database ############################################ my @file_array; my $in_file = "c:\\nursing_homes.txt"; my $out_file = "c:\\nursing_homes_out.txt"; if (-e $out_file) { unlink $out_file; } open INPUT,'<',$in_file or die "Can't open file " . $in_file . "\n$!\n"; #Open for read open OUTPUT,'>',$out_file or die "Can't open file " . $out_file . "\n$!\n"; #Open for write while () { chomp ($_); next if $_ =~ /^\s*$/; # skip over blank lines print OUTPUT $_ . "\n"; } close INPUT; close OUTPUT; open INPUT,'<',$out_file or die "Can't open file " . $out_file . "\n$!\n"; #Open for read while () { my $name = $connect->quote($_); next; my $address1 = $connect->quote($_); next; my $address2 = $connect->quote($_); next; my $phone = $connect->quote($_); next; next if (($_ =~ /^.*Council.*$/) || ($_ =~ /^Continuing.*$/) || ($_ =~ /^Mapping.*$/)); next if (($_ =~ /^.*Council.*$/) || ($_ =~ /^Continuing.*$/) || ($_ =~ /^Mapping.*$/)); next if (($_ =~ /^.*Council.*$/) || ($_ =~ /^Continuing.*$/) || ($_ =~ /^Mapping.*$/)); my $overall = $connect->quote($_); next; my $inspections = $connect->quote($_); next; my $staffing = $connect->quote($_); next; my $quality = $connect->quote($_); next; my $programs = $connect->quote($_); next; my $beds = $connect->quote($_); next; my $ownership = $connect->quote($_); next; my $query_string = "INSERT INTO nursing_homes (name, address1, address2, phone, overall, inspections, staffing, quality, programs, beds, ownership) VALUES ($name, $address1, $address2, $phone, $overall, $inspections, $staffing, $quality, $programs, $beds, $ownership)"; #printVariables($name, $address1, $address2, $phone, $overall, $inspections, $staffing, $quality, $programs, $beds, $ownership, $query_string); my $query_handle = $connect->prepare("INSERT INTO nursing_homes (name, address1, address2, phone, overall, inspections, staffing, quality, programs, beds, ownership) VALUES ($name, $address1, $address2, $phone, $overall, $inspections, $staffing, $quality, $programs, $beds, $ownership)"); $query_handle->execute(); } close INPUT; $connect->disconnect(); __END__ #### AARON MANOR REHABILITATION & NURSING CENTER 100 ST CAMILLUS WAY FAIRPORT, NY 14450 (585) 377-4000 Resident Council Mapping & Directions 4 out of 5 stars 4 out of 5 stars 3 out of 5 stars 4 out of 5 stars Medicare and Medicaid 140 For profit - Corporation ABSOLUT CTR FOR NURSING & REHAB ALLEGANY LLC 2178 NORTH FIFTH STREET ALLEGANY, NY 14706 (716) 373-2238 Resident & Family Councils Mapping & Directions 3 out of 5 stars 4 out of 5 stars 1 out of 5 stars 4 out of 5 stars Medicare and Medicaid 37 For profit - Corporation ABSOLUT CTR FOR NURSING & REHAB AURORA PARK LLC 292 MAIN STREET EAST AURORA, NY 14052 (716) 652-1560 Resident Council Mapping & Directions 1 out of 5 stars 1 out of 5 stars 2 out of 5 stars 4 out of 5 stars Medicare and Medicaid 320 For profit - Corporation ABSOLUT CTR FOR NURSING & REHAB DUNKIRK LLC 447 449 LAKE SHORE DRIVE WEST DUNKIRK, NY 14048 (716) 366-6710 Resident Council Mapping & Directions 1 out of 5 stars 2 out of 5 stars 1 out of 5 stars 2 out of 5 stars Medicare and Medicaid 40 For profit - Corporation