Greetings,

Could some please tell me why this writing the data like think it should.


Input data:
4,'Daniel Niederer','','Wberweg 3A','','Hersiwil','

Sample of the output:  (first 4 'columns' )
4,'Daniel Niederer','','Wberweg 3A','','Hersiwil','4558',

I would think it should print to disk the following ::

 0 : 4,'name: Daniel Niederer','','Wberweg 3A','','Hersiwil','4558',
 
 $customers_id= $count++ . " : ". $tmpArray[0] || "''";
$customers_name=  "name : " . $tmpArray[1] || ;


But it does not!!  <[EMAIL PROTECTED]@#>

If anyone can set me straight on how to make my script behave
that would be most helpful.

Thx!

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

---

#!/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";
}

$count =0;

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

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

# 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_method,$shipping_module_code,$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