Fix CSV import errors
[php-addressbook.git] / include / import.csv.php
index 4a0f5c7..4e1542c 100644 (file)
@@ -31,26 +31,22 @@ class ImportCsv extends ImportDel {
     //
     $delim = maxChar($delims, $test_line);
     $quote = maxChar($quotes, $test_line);
-    
-    //
-    // Re-Conncat the file-lines
-    //
-         $input = implode("\n", $file_lines)."\n";
-         
-    //
-         // Setup and run the parser
-    //
-    include "lib/parsecsv.lib.php";
-         $csv = new parseCSV();
-         $csv->delimiter = $delim;
-         $csv->enclosure = $quote;
-         $csv->file_data = &$input;      
-         $this->data = $csv->parse_string();
+
+    $escape = '\\';
+
+    for($i = 0; $i < count($file_lines); $i++) {
+        // Skip the first line (header)
+        if ($i > 0)
+        {
+            $row = str_getcsv($file_lines[$i], $delim, $quote, $escape);
+            $this->data[] = $row;
+        }
+    }
 
     //
     // Convert the array to addresses
-    //           
-    $this->convertToAddresses();
+    //
+    $this->convertToAddresses(); // Will populate ab
   }
 }
-?>
\ No newline at end of file
+?>