This is adding to many ',' in my output and do not see why!

Could some one could point where I have gone wrong.
Thanks,

Dave Gilden 
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)



data in: (one row of many)
35, 'Mike Hoffman', '', '2565 Davis Blvd. #177', '', 'Ft. Worth', '75252', 
'Texas', 'United States', '972267-2820', '[EMAIL PROTECTED]', 2, 'Mike 
Hoffman', '', '2565 Davis Blvd. #177', '', 'Ft.', '75252', 'Texas', 'United 
States', 2, 'Richard Hoffman', '', '6565 Davis Blvd. #177', '', 'Dallas', 
'75252', 'Texas', 'United States', 2, 'Authorize.net AIM', 'Visa', 'Richard 
Hoffman', '5446731215700551', '0807', '2007-07-03 15:12:30', '2007-07-02 
19:35:44', 3, NULL, 'USD', 1.000000, NULL

output #not correct  # note the end of this string
(35, 'Mike Hoffman', '', '2565 Davis Blvd. #177', '', 'Ft. worth', '75252', 
'Texas', 'United States', '972267-2820', '[EMAIL PROTECTED]', 2, 'Mike 
Hoffman', '', '2565 Davis Blvd. #177', '', 'Ft. worth', '75252', 'Texas', 
'United States', 2, 'Mike Hoffman', '', '2565 Davis Blvd. #177', '', 'Ft. 
worth', '75252', 'Texas', 'United States', 2, 'Authorize.net AIM', 'Visa', 
'Mike Hoffman', '5446731215700551', '0809', '2007-07-08 21:30:10', '2007-07-05 
16:01:48', 3, NULL, 'USD', 1.000000, 
NULL,'','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',,,'',,'','','','',,'','','','','','',,,,)

# note the end of this string
# why am I getting the extra [,] s

-----

#!/usr/bin/perl -w

$fileIn = "orders-raw.txt" ;
$CleanCSV = "clean_orders_insert.txt";


####
open (FH, $fileIn) or &errorMsg("Problem reading $fileIn $!\n");

while(<FH>){
push(@record, $_); 
} 
close FH;



sub errorMsg{
$_ = shift;
print "Error: $_\n";
}


open(CSV_OUT,">$CleanCSV") or &errorMsg( "Write out,  Could not write file: 
$CleanCSV, $!");
 
foreach (@record){
chomp;  
#Split each line
my @tmpArray  = split(/","/,$_); 
my @tmpArray  = split(/","/,$_); 

$customers_id = $tmpArray[0] || "''";
$customers_name = $tmpArray[1] || "''";
$customers_company = $tmpArray[2] || "''";
$customers_street_address = $tmpArray[3] || "''";
$customers_suburb = $tmpArray[4] || "''";
$customers_city = $tmpArray[5] || "''";
$customers_postcode = $tmpArray[6] || "''";
$customers_state = $tmpArray[7] || "''";
$customers_country = $tmpArray[8] || "''";
$customers_telephone = $tmpArray[9] || "''";
$customers_email_address = $tmpArray[10] || "''";
$customers_address_format_id = $tmpArray[11] || "''";
$delivery_name = $tmpArray[12] || "''";
$delivery_company = $tmpArray[13] || "''";
$delivery_street_address = $tmpArray[14] || "''";
$delivery_suburb = $tmpArray[15] || "''";
$delivery_city = $tmpArray[16] || "''";
$delivery_postcode = $tmpArray[17] || "''";
$delivery_state = $tmpArray[18] || "''";
$delivery_country = $tmpArray[19] || "''";
$delivery_address_format_id = $tmpArray[20] || "''";
$billing_name = $tmpArray[21] || "''";
$billing_company = $tmpArray[22] || "''";
$billing_street_address = $tmpArray[23] || "''";
$billing_suburb = $tmpArray[24] || "''";
$billing_city = $tmpArray[25] || "''";
$billing_postcode = $tmpArray[26] || "''";
$billing_state = $tmpArray[27] || "''";
$billing_country = $tmpArray[28] || "''";
$billing_address_format_id = $tmpArray[29] || "''";
$payment_method = $tmpArray[30] || "''";
$cc_type = $tmpArray[31] || "''";
$cc_owner = $tmpArray[32] || "''";
$cc_number = $tmpArray[33] || "''";
$cc_expires = $tmpArray[34] || "''";
$last_modified = $tmpArray[35] || "''";
$date_purchased = $tmpArray[36] || "''";
$orders_status = $tmpArray[37] || "''";
$orders_date_finished = $tmpArray[38] || "''";
$currency = $tmpArray[39] || "''";
$currency_value = $tmpArray[40] || "''";
$shipping_method = $tmpArray[41] || "''"; #shipping_module
# Write TMP file 
print CSV_OUT 
"($customers_id,$customers_name,$customers_company,$customers_street_address,$customers_suburb,$customers_city,$customers_postcode,$customers_state,$customers_country,$customers_telephone,$customers_email_address,$customers_address_format_id,$delivery_name,$delivery_company,$delivery_street_address,$delivery_suburb,$delivery_city,$delivery_postcode,$delivery_state,$delivery_country,$delivery_address_format_id,$billing_name,$billing_company,$billing_street_address,$billing_suburb,$billing_city,$billing_postcode,$billing_state,$billing_country,$billing_address_format_id,$payment_method,$payment_module_code,$shipping_module,$shipping_method,$coupon_code,$cc_type,$cc_owner,$cc_number,$cc_expires,$cc_cvv,$last_modified,$date_purchased,$orders_status,$orders_date_finished,$currency,$currency_value,$order_total,$order_tax,$paypal_ipn_id,$ip_address)\n";

}

close(CSV_OUT);


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to