Permalink
Browse files

Use str_getcsv() to parse lines of import file (#434)

  • Loading branch information...
bramley authored and samtuke committed Nov 8, 2018
1 parent 7e6a046 commit 93797bf83cc165ad288a025858b58b72093556f0
Showing with 4 additions and 12 deletions.
  1. +2 −6 public_html/lists/admin/actions/import2.php
  2. +2 −6 public_html/lists/admin/import2.php
@@ -28,9 +28,8 @@
$email_list = explode("\n", $email_list); //WARNING the file contents get replace by an array
output(sprintf('..'.$GLOBALS['I18N']->get('ok, %d lines').'</p>', count($email_list)));
$header = array_shift($email_list);
$header = str_replace('"', '', $header);
$total = count($email_list);
$headers = explode($_SESSION['import_field_delimiter'], $header);
$headers = str_getcsv($header, $_SESSION['import_field_delimiter']);
$headers = array_unique($headers);
$_SESSION['columnnames'] = $headers;
@@ -77,10 +76,7 @@
set_time_limit(60);
// will contain attributes to store / change
$user = array();
// get rid of text delimiters generally added by spreadsheet apps
$line = str_replace('"', '', $line);
$values = explode($_SESSION['import_field_delimiter'], $line);
$values = str_getcsv($line, $_SESSION['import_field_delimiter']);
$system_values = array();
foreach ($system_attribute_mapping as $column => $index) {
// print '<br/>'.$column . ' = '. $values[$index];
@@ -219,9 +219,8 @@
$email_list = explode("\n", $email_list); //WARNING the file contents get replace by an array
output(sprintf('..'.$GLOBALS['I18N']->get('ok, %d lines').'</p>', count($email_list)));
$header = array_shift($email_list);
$header = str_replace('"', '', $header);
$total = count($email_list);
$headers = explode($_SESSION['import_field_delimiter'], $header);
$headers = str_getcsv($header, $_SESSION['import_field_delimiter']);
$headers = array_unique($headers);
$_SESSION['columnnames'] = $headers;
@@ -506,10 +505,7 @@
set_time_limit(60);
// will contain attributes to store / change
$user = array();
// get rid of text delimiters generally added by spreadsheet apps
$line = str_replace('"', '', $line);
$values = explode($_SESSION['import_field_delimiter'], $line);
$values = str_getcsv($line, $_SESSION['import_field_delimiter']);
$system_values = array();
foreach ($system_attribute_mapping as $column => $index) {
// print '<br/>'.$column . ' = '. $values[$index];

0 comments on commit 93797bf

Please sign in to comment.