importexportapi_csv_get_parsed() breaks with empty $enclosure string.

sime - June 20, 2007 - 15:34
Project:Import / Export API
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

In trying to call importexportapi_csv_get_parsed() directly, over-riding the delimiter and enclosure strings, it seems that an empty enclosure (common in tab-delimited files), breaks the regex.

FWIW, my (simple) solution was to make my tab-delimited file look like a comma-separated with quote enclosures.

<?php
  $contents
= str_replace("\r\n", "\n", $contents);
 
$contents = str_replace("\n\r", "\n", $contents);
 
$contents = str_replace("\r", "\n", $contents);
 
$contents = "\"". str_replace("\n", "\"\n\"", str_replace("\t", "\",\"", $contents)) . "\"";
 
$result = importexportapi_csv_get_parsed($contents);
?>

 
 

Drupal is a registered trademark of Dries Buytaert.