Import records not working with csv file, works copy/paste
Posted: Thu Mar 24, 2011 11:55 am
Hello,
I have a csv file that will not import correctly when browsing for the file and clicking submit. It does import correctly if I copy and paste all the data in chunks to import(One shot via the copy and paste doesn't work either). The size for the file is 80kb which is under the max limit set by php. I've double and triple checked the columns to make sure its correct with the db.
Here is the error from php:
Notice: Undefined offset: 1 in /home/rodriguez3/public_html/Macro_Express_IRU/tables/orbitInventory/orbitInventory.php on line 18
Warning: Cannot modify header information - headers already sent by (output started at /home/rodriguez3/public_html/Macro_Express_IRU/tables/orbitInventory/orbitInventory.php:19) in /home/rodriguez3/public_html/xataface-1.2.6/actions/import.php on line 48
sample data:
Import Filter
Any ideas on how to resolve this and what could be causing the errors?
Thanks,
Juan
I have a csv file that will not import correctly when browsing for the file and clicking submit. It does import correctly if I copy and paste all the data in chunks to import(One shot via the copy and paste doesn't work either). The size for the file is 80kb which is under the max limit set by php. I've double and triple checked the columns to make sure its correct with the db.
Here is the error from php:
Notice: Undefined offset: 1 in /home/rodriguez3/public_html/Macro_Express_IRU/tables/orbitInventory/orbitInventory.php on line 18
Warning: Cannot modify header information - headers already sent by (output started at /home/rodriguez3/public_html/Macro_Express_IRU/tables/orbitInventory/orbitInventory.php:19) in /home/rodriguez3/public_html/xataface-1.2.6/actions/import.php on line 48
sample data:
- Code: Select all
UNET,Oldsmar IRU,OD1,OD1_BIL,0,4,1,2,1,3,1,1,0,0,13,0,0,0,0,0,0,0,0,0,0,0,0,0
UNET,Oldsmar IRU,OD1,OD1_CHMO,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0
UNET,Oldsmar IRU,OD1,OD1_COR,1,164,229,177,128,125,14,8,1,0,847,0,6,2,0,0,1,0,0,0,0,9,0,0
UNET,Oldsmar IRU,OD1,OD1_EXE,0,4,0,1,1,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0
UNET,Oldsmar IRU,OD1,OD1_FOR,0,7,36,9,6,2,1,0,0,1,62,0,0,0,0,0,0,0,0,0,0,0,0,0
Import Filter
- Code: Select all
<?php
class tables_orbitInventory
{
//function to import csv data into tables
function __import__csv(&$data, $defaultValues=array())
{
//build an array of dataface_record objects
$records = array();
//split the csv file into many rows
$rows = explode("\n", $data);
foreach ($rows as $row)
{
//iterate through rows to parse data
list($platform,$area,$office,$que,$age1,$age2,$age3,$age4,$age5,$age6,$age7,$age8,$age9,$age10,$age110,$age11,$age12,$age13,$age14,$age15,$age16,$age17,$age18,$age19,$age20,$age1120,$age2159,$age60) = explode(',', $row);
print_r($row);
print_r("<br />");
$record = new Dataface_Record('orbitInventory', array());
//insert default values
$record->setValues($defaultValues);
//now we add the values from the csv file
$record->setValues(
array(
'platform' =>$platform,
'area' => $area,
'office' => $office,
'que' => $que,
'age1' => $age1,
'age2' => $age2,
'age3' => $age3,
'age4' => $age4,
'age5' => $age5,
'age6' => $age6,
'age7' => $age7,
'age8' => $age8,
'age9' => $age9,
'age10' => $age10,
'age110' => $age110,
'age11' => $age11,
'age12' => $age12,
'age13' => $age13,
'age14' => $age14,
'age15' => $age15,
'age16' => $age16,
'age17' => $age17,
'age18' => $age18,
'age19' => $age19,
'age20' => $age20,
'age1120' => $age1120,
'age2159' => $age2159,
'age60' => $age60,)
);
//now add the record to the output array
$records[] = $record;
}
//Now we return the array of records to be imported
return $records;
}
}
?>
Any ideas on how to resolve this and what could be causing the errors?
Thanks,
Juan