From b1ed887fcf84e628ae3159e1dc6a117dd9bd8ec5 Mon Sep 17 00:00:00 2001 From: olivier Date: Mon, 16 Jun 2008 19:49:44 +0000 Subject: [PATCH] raw_conversion: fix handling of control caracters git-svn-id: http://svn.parisson.org/svn/crem@30 3bf09e05-f825-4182-b9bc-eedd7160adf0 --- import/raw_conversion/README | 1 + import/raw_conversion/export.4d.txt | 16 ++++++++++++---- import/raw_conversion/import | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/import/raw_conversion/README b/import/raw_conversion/README index 2ea95be..17f2195 100644 --- a/import/raw_conversion/README +++ b/import/raw_conversion/README @@ -35,6 +35,7 @@ copie de la base 4D, et non sur la version de production. 4. Créer une base MySQL, par exemple: crem 5. Importer la toutes les données dans la base MySQL avec la commande:: + ./import /tmp/export_crem | mysql -vvv crem Vérifiez que chaque requête se termine par "Query OK" avec "Warnings: 0", diff --git a/import/raw_conversion/export.4d.txt b/import/raw_conversion/export.4d.txt index 4f7beff..bd30cd6 100755 --- a/import/raw_conversion/export.4d.txt +++ b/import/raw_conversion/export.4d.txt @@ -80,6 +80,7 @@ Boucle ($tableNumber;1;$numberOfTables) $fieldValue:=$fieldPtr->   $fieldValue:=Remplacer chaine ($fieldValue; $fieldDelimiter; " ") $fieldValue:=Remplacer chaine ($fieldValue; $recordDelimiter; " ") + $fieldValue:=Remplacer chaine ($fieldValue; Caractere(13); " ") Fin de cas Si ($fieldNumber#$numberOfFields)   @@ -113,10 +114,12 @@ Fin de boucle `Export des relations des formations +$tab:=Caractere(9) +$fin:=Caractere(10) +$ret:=Caractere(13) + $doc:=Creer document("c:\export_crem\Formation.txt";"TXT") Si (ok=1) - $tab:=Caractere(9) - $fin:=Caractere(10) $texte:="Cote_Phono"+$tab+"Instr_Scientif"+$tab+"Instr_Vernacul"+$tab+"Interprète"+$tab+"Total_Instrum"+$fin ENVOYER PAQUET($doc;Mac vers Windows($texte)) TOUT SELECTIONNER([Phono]) @@ -124,16 +127,21 @@ Si (ok=1) $cote:=[Phono]Cote_Phono $cote:=Remplacer chaine($cote; $tab; " ") $cote:=Remplacer chaine($cote; $fin; " ") + $cote:=Remplacer chaine($cote; $ret; " ") TOUS LES SOUS ENREGISTREMENTS([Phono]Formation) Boucle ($j;1;Sous enregistrements trouves([Phono]Formation) $instr_scientif:=Remplacer chaine([Phono]Formation'Instr_Scientif; $tab; " ") $instr_scientif:=Remplacer chaine($instr_scientif; $fin; " ") + $instr_scientif:=Remplacer chaine($instr_scientif; $ret; " ") $instr_vernacul:=Remplacer chaine([Phono]Formation'Instr_Vernacul; $tab; " ") $instr_vernacul:=Remplacer chaine($instr_vernacul; $fin; " ") + $instr_vernacul:=Remplacer chaine($instr_vernacul; $ret; " ") $interprete:=Remplacer chaine([Phono]Formation'Interprète; $tab; " ") $interprete:=Remplacer chaine($interprete; $fin; " ") + $interprete:=Remplacer chaine($interprete; $ret; " ") $total:=Remplacer chaine([Phono]Formation'Total_Instrum; $tab; " ") $total:=Remplacer chaine($total; $fin; " ") + $total:=Remplacer chaine($total; $ret; " ") $texte:=$cote+$tab+$instr_scientif+$tab+$instr_vernacul+$tab+$interprete+$tab+$total+$fin ENVOYER PAQUET($doc;Mac vers Windows($texte)) SOUS ENREGISTREMENT SUIVANT([Phono]Formation) @@ -150,8 +158,6 @@ Fin de si $doc:=Creer document("c:\export_crem\Fonction_Usage.txt";"TXT") Si (ok=1) - $tab:=Caractere(9) - $fin:=Caractere(10) $texte:="Cote_Phono"+$tab+"Mot_Clef"+$fin ENVOYER PAQUET($doc;Mac vers Windows($texte)) TOUT SELECTIONNER([Phono]) @@ -159,10 +165,12 @@ Si (ok=1) $cote:=[Phono]Cote_Phono $cote:=Remplacer chaine($cote; $tab; " ") $cote:=Remplacer chaine($cote; $fin; " ") + $cote:=Remplacer chaine($cote; $ret; " ") TOUS LES SOUS ENREGISTREMENTS([Phono]Fonction_Usage) Boucle ($j;1;Sous enregistrements trouves([Phono]Fonction_Usage) $mot_clef:=Remplacer chaine([Phono]Fonction_Usage'Mot_Clef; $tab; " ") $mot_clef:=Remplacer chaine($mot_clef; $fin; " ") + $mot_clef:=Remplacer chaine($mot_clef; $ret; " ") $texte:=$cote+$tab+$mot_clef+$fin ENVOYER PAQUET($doc;Mac vers Windows($texte)) SOUS ENREGISTREMENT SUIVANT([Phono]Fonction_Usage) diff --git a/import/raw_conversion/import b/import/raw_conversion/import index cdfb1c3..2d694c4 100755 --- a/import/raw_conversion/import +++ b/import/raw_conversion/import @@ -30,7 +30,7 @@ do echo "LOAD DATA INFILE '$src/$filename'" echo " INTO TABLE \`$table\`" echo " CHARACTER SET 'latin1'" - echo " FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'" + echo " FIELDS TERMINATED BY '\t' ESCAPED BY '' LINES TERMINATED BY '\n'" echo " IGNORE 1 LINES;" echo "SHOW WARNINGS;" echo -- 2.39.5