IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

HyperFileSQL Discussion :

Importantion CSV dans HPSQL


Sujet :

HyperFileSQL

  1. #1
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut Importantion CSV dans HPSQL
    Bonjour à tous,

    Peut-être que le topic a déjà été traité ici, mais je me permet d'ouvrir celui parce que je ne reçois aucun message d'erreur par contre ma table ne se remplit pas.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    sMonFichierEXPRESS est une chaîne
    nLireLigne est une chaîne
    nIdFichierEXPRESS est un entier
     
    sMonFichierEXPRESS = "G:\Table_Agence.csv"
    nIdFichierEXPRESS = fOuvre(sMonFichierEXPRESS)
     
    //nLireLigne = nIDFichier 
    SI nIdFichierEXPRESS<>-1 ALORS 
     
    	VarSorti est un booléen = Faux // pour sortir de la boucle
    	Erreur(ErreurInfo(errMessage))
     
    	BOUCLE 
    		nLireLigne = fLitLigne(nIdFichierEXPRESS)
    		EXPRESS_Agence.IDAgence = ExtraitChaîne(nLireLigne, 2, ",")
    		EXPRESS_Agence.LibelleAgence = ExtraitChaîne(nLireLigne,3,",")
    		EXPRESS_Agence.IDEXPRESS_Banque = ExtraitChaîne(nLireLigne,4,",")
    		HAjoute(EXPRESS_Agence)
     
    		SI fLitLigne(nIdFichierEXPRESS) = EOT ALORS 
    			VarSorti = Vrai
    		FIN
     
    		// Doit-on sortir de la boucle
    		SI VarSorti = Vrai ALORS SORTIR
     
    	FIN	
     
    	Info ("Insertion éffectuée avec succès !!!!")
    	fFerme(nIdFichierEXPRESS)
    SINON
    	Info("Insertion non éffectuée, réverifiez le code")
    	fFerme(nIdFichierEXPRESS)
    FIN
    Quelqu'un a une idée sur ce problème ?
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

  2. #2
    Expert éminent
    Avatar de frenchsting
    Homme Profil pro
    multitâches-multifonctions
    Inscrit en
    Juin 2003
    Messages
    5 202
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : multitâches-multifonctions
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2003
    Messages : 5 202
    Points : 9 190
    Points
    9 190
    Par défaut
    1. Essaye le mode test et mets des points d'arrêt.
    2. Y'a t'il un message d'erreur ?
    3. Quelle version de Windev utilises tu ?

    Tu peux simplifier ton code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    sMonFichierEXPRESS, sContenu, sUneligne sont des chaines
    i est un entier = 0
     
    sMonFichierEXPRESS = "G:\Table_Agence.csv"
    sContenu=fchargetexte(sMonFichierEXPRESS)
    //nLireLigne = nIDFichier 
    Pour tout sUneligne de sContenu separe par rc
    	EXPRESS_Agence.IDAgence = ExtraitChaîne(sUneligne , 2, ",")
    	EXPRESS_Agence.LibelleAgence = ExtraitChaîne(sUneligne ,3,",")
    	EXPRESS_Agence.IDEXPRESS_Banque = ExtraitChaîne(sUneligne ,4,",")
    	HAjoute(EXPRESS_Agence)
    	i++
     FIN	
     
    Info ("Traitement terminé !!!!", numeriqueversChaine(i) + " lignes enregistrées")
    Essaye avec mon code (à peaufiner car fait à l'arrache)
    Commencez toujours appuyer sur la touche F1 et puis n'hésitez à passer par un moteur de recherche...
    Le forum est fait pour répondre aux questions : pas la peine de me les envoyer par MP. Merci.

    Sur internet, tout est vrai ! Honoré de Balzac
    Make it real not fantasy... Herman Rarebell

  3. #3
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut
    Bonjour frenchsting,

    1. Essaye le mode test et mets des points d'arrêt.
    2. Y'a t'il un message d'erreur ?

    Idem pour 1, et pas de message d'erreur.

    3. Quelle version de Windev utilises tu ? : La 19.

    J'aimerai pouvoir effectuer ce test pour ensuite générer à partir de ma table un fichier texte.

    J'ai adapté ton code, mais un problème avec la boucle.
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

  4. #4
    Membre émérite
    Femme Profil pro
    .
    Inscrit en
    Janvier 2012
    Messages
    999
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : .
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Janvier 2012
    Messages : 999
    Points : 2 525
    Points
    2 525
    Par défaut
    Bien entendu, tu es sûr que le séparateur est une virgule.
    Juste comme ça.

  5. #5
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut
    Citation Envoyé par serendib Voir le message
    Bien entendu, tu es sûr que le séparateur est une virgule.
    Juste comme ça.
    Oui, c'est bien une virgule.

    J'ai supprimer la 1ère colonne qui contient les noms des champs et commencer la lecture à la 1ère ligne.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    sMonFichierEXPRESS, sContenu, sUneligne sont des chaînes
    i est un entier = 0
     
    sMonFichierEXPRESS = "G:\Table_Agence.csv"
    sContenu=fChargeTexte(sMonFichierEXPRESS)
    //nLireLigne = nIDFichier 
    POUR TOUT sUneligne DE sContenu separe par RC
    	EXPRESS_Table_Agence.Code_agence = ExtraitChaîne(sUneligne , 1, ",")
    	EXPRESS_Table_Agence.Libelle = ExtraitChaîne(sUneligne ,2,",")
    	EXPRESS_Table_Agence.Code_banque = ExtraitChaîne(sUneligne ,3,",")
    	EXPRESS_Table_Agence.Express_Version = ExtraitChaîne(sUneligne,4,",")
    	HAjoute(EXPRESS_Table_Agence)
    	i++
    FIN	
     
    Info ("Traitement terminé !!!!", NumériqueVersChaîne(i) + " lignes enregistrées")
    Il me dit que :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    "par" est un mot clé du WLangage, son utilisation dans ce cas est incorrect
    J'ai fait 2 boutons : Charger_CSV et Creer_TXT.
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

  6. #6
    Expert éminent
    Avatar de frenchsting
    Homme Profil pro
    multitâches-multifonctions
    Inscrit en
    Juin 2003
    Messages
    5 202
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : multitâches-multifonctions
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2003
    Messages : 5 202
    Points : 9 190
    Points
    9 190
    Par défaut
    J'ai fait une erreur en tapant mon code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    POUR TOUTe CHAINE  sUneligne DE sContenu separe par RC
    Cela devrait mieux fonctionner...
    Commencez toujours appuyer sur la touche F1 et puis n'hésitez à passer par un moteur de recherche...
    Le forum est fait pour répondre aux questions : pas la peine de me les envoyer par MP. Merci.

    Sur internet, tout est vrai ! Honoré de Balzac
    Make it real not fantasy... Herman Rarebell

  7. #7
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut
    Citation Envoyé par frenchsting Voir le message
    J'ai fait une erreur en tapant mon code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    POUR TOUTe CHAINE  sUneligne DE sContenu separe par RC
    Cela devrait mieux fonctionner...
    C'est pareil.

    Capture jointe. Nom : Error_Load_CSV.png
Affichages : 262
Taille : 37,8 Ko
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

  8. #8
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut
    ça marche maintenant

    La véritable syntaxe était :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    POUR TOUTE CHAÎNE sUneligne DE sContenu SEPAREE PAR RC
    Merci frenchsting
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [MySQL] Importer les données d'un fichier CSV dans une base de données
    Par joueur dans le forum PHP & Base de données
    Réponses: 7
    Dernier message: 12/11/2008, 11h59
  2. Importer CSV dans MySQL
    Par The_freeman dans le forum Administration
    Réponses: 6
    Dernier message: 14/02/2006, 22h18
  3. [VB6] Fichier csv dans un recordset
    Par Mymi dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 18/01/2006, 22h19
  4. Importer un fichier CSV dans un clientdataset ?
    Par mls dans le forum Bases de données
    Réponses: 7
    Dernier message: 15/04/2005, 12h35
  5. Comment importer un document CSV dans une table MySql ?
    Par magic8392 dans le forum Requêtes
    Réponses: 6
    Dernier message: 04/02/2005, 11h03

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo