[SPIP Zone] r3837 - /_plugins_/_contenu_editorial_/CSVImport/inc/csvimport.php

Author: cedric@yterium.com
Date: Fri Jul 7 11:57:59 2006
New Revision: 3837

Log:
importer le charset lors de l'import csv

Modified:
    _plugins_/_contenu_editorial_/CSVImport/inc/csvimport.php

Modified: _plugins_/_contenu_editorial_/CSVImport/inc/csvimport.php

--- _plugins_/_contenu_editorial_/CSVImport/inc/csvimport.php (original)
+++ _plugins_/_contenu_editorial_/CSVImport/inc/csvimport.php Fri Jul 7 11:57:59 2006
@@ -184,14 +184,22 @@
  * @param int $len Line length to be passed to fgetcsv
  * @return array or false on failure to retrieve any rows.
  */
+
+function csvimport_importcharset($texte){
+ return importer_charset($texte, 'iso-8859-1');
+}
+
function csvimport_importcsv($file, $head = false, $delim = ",", $enclos = '"', $len = 1000) {
+ include_spip('inc/charset');
    $return = false;
    $handle = fopen($file, "r");
    if ($handle){
      if ($head) {
          $header = fgetcsv($handle, $len, $delim);
+ $header = array_map('csvimport_importcharset',$header);
      }
      while (($data = fgetcsv($handle, $len, $delim)) !== FALSE) {
+ $data = array_map('csvimport_importcharset',$data);
          if ($head AND isset($header)) {
              foreach ($header as $key=>$heading) {
                  $row[$heading]=(isset($data[$key])) ? $data[$key] : '';

Le 7 juil. 06 à 11:57, cedric@yterium.com a écrit :

Author: cedric@yterium.com
Date: Fri Jul 7 11:57:59 2006
New Revision: 3837

Log:
importer le charset lors de l'import csv

Modified:
    _plugins_/_contenu_editorial_/CSVImport/inc/csvimport.php

Modified: _plugins_/_contenu_editorial_/CSVImport/inc/csvimport.php

Bonsoir,
Je réussi à exporter des tables (dont je me sert de modèle pour l'importation) mais l'importation est impossible (même avec la dernière version du plugin) :

ecrire/?exec=csvimport_import&table=spip_auteurs&retour=%3Fexec%3Dcsvimport_tous

me donne :
Warning: array_keys(): The first argument should be an array in /.../plugins/_contenu_editorial_/CSVImport/inc/csvimport.php on line 356

Warning: array_flip(): The argument should be an array in /.../plugins/_contenu_editorial_/CSVImport/inc/csvimport.php on line 357

Warning: array_keys(): The first argument should be an array in /.../plugins/_contenu_editorial_/CSVImport/inc/csvimport.php on line 389

Warning: Invalid argument supplied for foreach() in /.../plugins/_contenu_editorial_/CSVImport/inc/csvimport.php on line 389

Warning: array_keys(): The first argument should be an array in /.../plugins/_contenu_editorial_/CSVImport/inc/csvimport.php on line 399

Warning: Invalid argument supplied for foreach() in /.../plugins/_contenu_editorial_/CSVImport/inc/csvimport.php on line 399

puis lors de la prévisualisation :

Warning: array_keys(): The first argument should be an array in /.../plugins/_contenu_editorial_/CSVImport/inc/csvimport.php on line 412

Warning: Invalid argument supplied for foreach() in /.../plugins/_contenu_editorial_/CSVImport/inc/csvimport.php on line 419

et enfin lors de la phase "ajouter à la table" : 3::Correspondances CSV-Table non définies

Idem avec breves

Quelqu'un(e) peut-il m'éclairer. Merci d'avance.
Pierre