--- parser_csv_parser.inc	2008-12-16 08:46:52.000000000 -0500
+++ parser_csv_parser.inc	2009-01-13 17:52:32.000000000 -0500
@@ -76,90 +76,12 @@ function parser_csv_parse(Iterator $line
       continue;
     }
 
-    // The actual parser. explode() is unfortunately not suitable because the
-    // delimiter might be located inside a quoted field, and that would break
-    // the field and/or require additional effort to re-join the fields.
-    $quoted = FALSE;
-    $currentIndex = 0;
-    $currentField = '';
     $fields = array();
+    $expr="/$delimiter(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/"; // added 
 
-    while ($currentIndex <= strlen($line)) {
-      if ($quoted) {
-        $nextQuoteIndex = strpos($line, '"', $currentIndex);
+		$fields = preg_split($expr,trim($line));
+		$fields = preg_replace("/^\"(.*)\"$/","$1",$fields);
 
-        if ($nextQuoteIndex === FALSE) {
-          // There's a line break before the quote is closed, so fetch the
-          // next line and start from there.
-          $currentField .= substr($line, $currentIndex);
-          $lineIterator->next();
-
-          if (!$lineIterator->valid()) {
-            // Whoa, an unclosed quote! Well whatever, let's just ignore
-            // that shortcoming and record it nevertheless.
-            $fields[] = $currentField;
-            break;
-          }
-          // Ok, so, on with fetching the next line, as mentioned above.
-          $currentField .= "\n";
-          $line = trim($lineIterator->current(), "\r\n");
-          $currentIndex = 0;
-          continue;
-        }
-
-        // There's actually another quote in this line...
-        // find out whether it's escaped or not.
-        $currentField .= substr($line, $currentIndex, $nextQuoteIndex - $currentIndex);
-
-        if ($line[$nextQuoteIndex + 1] === '"') {
-          // Escaped quote, add a single one to the field and proceed quoted.
-          $currentField .= '"';
-          $currentIndex = $nextQuoteIndex + 2;
-        }
-        else {
-          // End of the quoted section, close the quote and let the
-          // $quoted == FALSE block finalize the field.
-          $quoted = FALSE;
-          $currentIndex = $nextQuoteIndex + 1;
-        }
-      }
-      else { // $quoted == FALSE
-        // First, let's find out where the next character of interest is.
-        $nextQuoteIndex = strpos($line, '"', $currentIndex);
-        $nextDelimiterIndex = strpos($line, $delimiter, $currentIndex);
-
-        if ($nextQuoteIndex === FALSE) {
-          $nextIndex = $nextDelimiterIndex;
-        }
-        elseif ($nextDelimiterIndex === FALSE) {
-          $nextIndex = $nextQuoteIndex;
-        }
-        else {
-          $nextIndex = min($nextQuoteIndex, $nextDelimiterIndex);
-        }
-
-        if ($nextIndex === FALSE) {
-          // This line is done, add the rest of it as last field.
-          $currentField .= substr($line, $currentIndex);
-          $fields[] = $currentField;
-          break;
-        }
-        elseif ($line[$nextIndex] === $delimiter[0]) {
-          $length = ($nextIndex + strlen($delimiter) - 1) - $currentIndex;
-          $currentField .= substr($line, $currentIndex, $length);
-          $fields[] = $currentField;
-          $currentField = '';
-          $currentIndex += $length + 1;
-          // Continue with the next field.
-        }
-        else { // $line[$nextIndex] == '"'
-          $quoted = TRUE;
-          $currentField .= substr($line, $currentIndex, $nextIndex - $currentIndex);
-          $currentIndex = $nextIndex + 1;
-          // Continue this field in the $quoted == TRUE block.
-        }
-      }
-    }
     // End of CSV parser. We've now got all the fields of the line as strings
     // in the $fields array.
 
@@ -173,6 +95,7 @@ function parser_csv_parse(Iterator $line
         $row[$columnName] = isset($field) ? $field : '';
       }
     }
+    
     $rows[] = $row;
   }
   return $rows;
