try { $row = explode('||', $line); if (count($row) == 5) { /* the data has valid number of elements, filter for any abnormalities in the data*/ $name = $row[0]; $name = str_replace("'", "''", $name); $address = $row[1]; $contacts = relinquishContacts($row[2]); $phone = $contacts[0]; $email = $contacts[1]; $website = $contacts[2]; $categoryLabel = $row[3]; $position = $row[4]; //create the category for the poi $category = new Category(); $category->init($parentController->getParentCategory($categoryLabel), $categoryLabel, $user); if ($id = $categoryController->add($category)) { $category->setId($id); //create the poi object $poi = new POI(); $poi->init($name, $address, $position, $category, $phone, $email, $website, "", $user); if ($poiController->add($poi)) { $insertCount++; } else { $skippedData[] = $line . "\n"; } } else { $skippedData[] = $line . "\n"; } } else { /* skip this data as it contains invalid number of data*/