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

WinDev Discussion :

Fichier Texte en Entrée et en Sortie


Sujet :

WinDev

  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 Fichier Texte en Entrée et en Sortie
    Bonjour,

    ça fait un moment que je suis au bureau, mais tous les bouts de code que j'ai testé ne repondent pas à mes souhaits. Pour aller plus vite, je vous mets un exemple de fichier texte que je veux lire en entrée et produire un autre texte, avec juste quelques champs du 1er avec ces valeurs.

    J'ai essayé avec en créant une nouvelle analyse, mais je bute sur le formatage du fichier input. Je n'arrive pas à comprendre sa structure.

    Si quelqu'un peut me filer un coup de main?

    Milles merci d'avance.

    PS : Le fichier FICHIER_ENTRE.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.

  2. #2
    Membre actif
    Homme Profil pro
    Développeur COBOL
    Inscrit en
    Mai 2015
    Messages
    138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur COBOL

    Informations forums :
    Inscription : Mai 2015
    Messages : 138
    Points : 270
    Points
    270
    Par défaut
    Bonjour,

    Tout D'abord merci, je ne connaissais pas cette instruction, quand je manipule du fichier texte j'utilise les instruction fouvre, flitligne, fecrit et fferme,
    Mais j'ai ouvert ton fichier et il me fait plus penser a un listing papier qu'a un fichier texte avec une structure. La question qui me vient donc a l'esprit
    que veux-tu récupérer dedans ? En fait je penserais a tester a chaque lecture de ligne le contenu de la ligne lue pour savoir a quelle type de ligne j'ai à
    faire entete/corps/total ou sous-total. En espérant avoir pu t'aider un tout petit peu.

  3. #3
    Expert éminent
    Avatar de frenchsting
    Homme Profil pro
    multitâches-multifonctions
    Inscrit en
    Juin 2003
    Messages
    5 207
    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 207
    Points : 9 208
    Points
    9 208
    Par défaut
    Un conseil RudolphRudolph, plutôt que les flitxxx, utilise plutôt les fchargetexte. Le temps de traitement va fortement diminuer.

    Concernant le himportetexte, je n'ai jamais réussi à le faire fonctionner correctement.

    Pour le cas de _shuriken_, le himportetexte ne fonctionnera pas. Il faut un type CSV : toujours le même cadrage (mêmes données sur chaque ligne).

    Pour moi, il faut faire un automate à états finis pour lire le fichier. Il faut orienter les données suivant les infos contenues dans la ligne courante ou la ligne précédente.
    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

  4. #4
    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 à tous,

    Merci à tous pour ce retour.

    frenchsting, Donc je devrai régénéré mon fichier en CSV ? Comment puis-je créer cet automate à états finis ?

    rudolfrudolf, J'ai plusieurs champs, mais à la sortie je n'en récupérerai que quelques uns.
    "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.

  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
    J'ai pu avoir un format Excel aussi, et j'essaie de joindre le métier pour qu'ils me fournissent un format CSV.

    j'attends leur retour.
    Joint DailyActivity130515.xls
    "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
    Membre actif
    Homme Profil pro
    Développeur COBOL
    Inscrit en
    Mai 2015
    Messages
    138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur COBOL

    Informations forums :
    Inscription : Mai 2015
    Messages : 138
    Points : 270
    Points
    270
    Par défaut
    Avec le fichier excel tu peux aussi utiliser les instructions xlsouvre / xlsdonnée /xlsnblig / xlsnbcol et xlsferme et xlssauve pour la sortie

    La question que je me pose est que sont les infos (champs/cellules) que tu veux récupérer dans ce fichier ?

    Ps:@ frenchsting merci pour ton conseil - a l'occase je regarderais cette instruction pour voir.

  7. #7
    Expert éminent
    Avatar de frenchsting
    Homme Profil pro
    multitâches-multifonctions
    Inscrit en
    Juin 2003
    Messages
    5 207
    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 207
    Points : 9 208
    Points
    9 208
    Par défaut
    Peu importe le format. CSV ou texte brut.

    Un automate à état fini est une méthode d’algorithmique qui permet de découper les fonctionnalités que l'on a a coder.
    Dans ton cas : si je lis A, alors je fais TrtA. Si je lis B alors je fais TrtB, etc..
    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

  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
    Je vois,

    ça risque d'être lourd en terme de traitement, mais on dirait que c'est la seule issue.

    Tu as un exemple à me fournir ?
    "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.

  9. #9
    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 rudolfrudolf Voir le message
    Avec le fichier excel tu peux aussi utiliser les instructions xlsouvre / xlsdonnée /xlsnblig / xlsnbcol et xlsferme et xlssauve pour la sortie

    La question que je me pose est que sont les infos (champs/cellules) que tu veux récupérer dans ce fichier ?

    Ps:@ frenchsting merci pour ton conseil - a l'occase je regarderais cette instruction pour voir.
    Si c'était les champs, ça allait me faciliter la tache en ayant déjà une idée sur le séparateur de champs.

    Mais d'après les explications de frenchsting, on doit plus agir sur les lignes en faisant des checking sur le motif à récupérer.

    Capture du fichier texte à importe Nom : Fichier_Texte_A_Importer.png
Affichages : 355
Taille : 55,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.

  10. #10
    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
    J'ai tenté avec ça, mais il me faudrait vraiment connaitre un exemple d'automate à états finis pour l'intégrer :

    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    MonFichier est une chaîne
    NIdFichier est un entier
     
    MonFichier = fChargeTexte("G:\Support & Exploitation\TransBal\DailyActivity130515.txt")
    NIdFichier = fOuvre(MonFichier)
     
     
     
    SI NIdFichier<>-1 ALORS 
     
    	VarSorti est un booléen = Faux // pour sortir de la boucle
    	Erreur(ErreurInfo(errMessage))
     
    	BOUCLE 
     
    		nLireLigne est une chaîne = fLitLigne(NIdFichier)
     
    		//Récupération des valeurs
    		sLegacyID est une chaîne = ExtraitChaîne(nLireLigne,6,DepuisDébut)
    		sTransactionType est une chaîne = ExtraitChaîne(nLireLigne,5,DepuisDébut)
    		BaseAmount est une chaîne = ExtraitChaîne(nLireLigne,11,DepuisDébut)
    		CommissionAmount est une chaîne = ExtraitChaîne(nLireLigne,17,DepuisDébut)
     
     
    		// Ouverture du fichier
    		NIdFichier = fOuvre("C:\Users\490drame\Desktop\FICHIER_SORTIE.txt", foLectureEcriture + foCréation)
    		SI NIdFichier <> -1 ALORS
     
    			fEcritLigne(NIdFichier,sLegacyID+TAB+sTransactionType+TAB+BaseAmount+TAB+CommissionAmount)
    			// Fermeture du fichier
    			fFerme(NIdFichier)
    		SINON
    			Erreur()
    		FIN
     
     
    		SI fLitLigne(NIdFichier) = 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(NIdFichier)
    SINON
    	Info("Insertion non éffectuée, réverifiez le code")
    	fFerme(NIdFichier)
    FIN
    Pour l'instant ce code ne crée rien, parce que je ne lui ait pas spécifié les motif à récupérer.
    "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.

  11. #11
    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
    Bon,

    J'ai essayé de régénerer moi même le fichier du métier, en ceci : FICHIER_ENTRE.txt

    Après ce bout de code, pour essayer de récupérer les positions et valeurs des champs :
    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    MonFichier est une chaîne
    NIdFichier est un entier
     
    //MonFichier = HImporteTexte(Feuil1$, "C:\Users\490drame\Desktop\FICHIER_ENTRE.txt", "", ";" + Caract(127) + ";" + Caract(127) + RC, hImpNormal)
     
    MonFichier = fChargeTexte("C:\Users\490drame\Desktop\FICHIER_ENTRE.txt")
     
    SI ErreurDétectée ALORS
    	Erreur(HErreurInfo())
    FIN
    NIdFichier = fOuvre(MonFichier)
     
     
     
    SI NIdFichier<>-1 ALORS 
     
    	VarSorti est un booléen = Faux // pour sortir de la boucle
    	Erreur(ErreurInfo(errMessage))
     
    	BOUCLE 
     
    		nLireLigne est une chaîne = fLitLigne(NIdFichier)
     
    		//Récupération des valeurs
    		sLegacyID est une chaîne = ExtraitChaîne(nLireLigne,9,";")
    		sTransactionType est une chaîne = ExtraitChaîne(nLireLigne,11,";")
    		BaseAmount est une chaîne = ExtraitChaîne(nLireLigne,27,";")
    		CommissionAmount est une chaîne = ExtraitChaîne(nLireLigne,38,";")
     
     
    		// Ouverture du fichier
    		NIdFichier = fOuvre("C:\Users\490drame\Desktop\FICHIER_S.txt", foLectureEcriture + foCréation)
    		SI NIdFichier <> -1 ALORS
     
    			fEcritLigne(NIdFichier,sLegacyID+TAB+sTransactionType+TAB+BaseAmount+TAB+CommissionAmount)
    			// Fermeture du fichier
    			fFerme(NIdFichier)
    		SINON
    			Erreur()
    		FIN
     
     
    		SI fLitLigne(NIdFichier) = 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(NIdFichier)
    SINON
    	Info("Insertion non éffectuée, réverifiez le code")
    	fFerme(NIdFichier)
    FIN
    "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.

  12. #12
    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 à tous,

    J'ai une piste mais je ne sais pas si c'est faisable sous Windev.

    En connaissant la ligne et la colonne de chaque élément, est-il possible de passer ces paramètres à une fonction ?
    "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.

  13. #13
    Rédacteur/Modérateur

    Avatar de dsr57
    Homme Profil pro
    Analyste programmeur senior
    Inscrit en
    Octobre 2003
    Messages
    1 139
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Analyste programmeur senior
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2003
    Messages : 1 139
    Points : 4 681
    Points
    4 681
    Billets dans le blog
    22
    Par défaut
    Bonjour

    Pour le passage de paramètres à une fonction, je t'invite à consulter l'aide en ligne : Passage de paramètres

    Bon dev
    ------------------------------------------------------------------------------------------------------------------------------------------
    Mon message vous a aidé, pensez à remercier . La discussion est résolue, n'oubliez pas le tag
    ------------------------------------------------------------------------------------------------------------------------------------------
    Site perso : Formation, Expérience, Réalisations, ...
    Blog : Le Blog de DSR57 - Programmation WinDev

  14. #14
    Expert éminent
    Avatar de frenchsting
    Homme Profil pro
    multitâches-multifonctions
    Inscrit en
    Juin 2003
    Messages
    5 207
    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 207
    Points : 9 208
    Points
    9 208
    Par défaut
    Tu fais des trucs bizarres dans ton code : un fchargetexte suivi d'un fouvre....

    Exemple (sommaire et imcomplet) d'un automate
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    sContenu,sUneLigne sont des chaines
    sContenu = fChargeTexte("C:\Users\490drame\Desktop\FICHIER_ENTRE.txt")
    pour toute chaine sUnligne de sContenu Separee par RC
    si sansespace(remplace(sUbligne,TAB,"") = "" alors continuer // ignorer les lignes vides
    si position(majuscule(sUnligne),"ACCOUNT NUMBER") > 0 alors TrtAccountNumber(SUneLigne) // Si on a une ligne account number
    si datevalide(extraitchaine(sUnligne,1,tab)) alors TrtLigneArticle(sUneLigne) // une ligne d'article
    ...
    fin
    Il manque le traitement de l'identité du client (3 premières lignes de ton fichier exemple). Mais ça te donne une idée du fonctionnement.
    La difficulté vient du fait que l'on ne sait pas combien de lignes articles tu vas avoir.

    Par contre, tu peux prédire qu'après une ligne "Account number", tu vas avoir une ligne "Legacy ID", et qu'après une ligne "Legacy ID", tu vas avoir une ligne Article. Et ce système de "prédictions" est le principe de fonctionnement d'un automate à états finis.
    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

  15. #15
    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,

    J'ai carrément modifié mon code.

    J'essaie d'utiliser le format Excel avec la fonction xlsOuvre.

    Ma table ne se remplie toujours pas et je n'ai aucun message d'erreur, non plus en mode debug.

    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    IdFichierXLS est un entier = xlsOuvre(SC_SelecteurFichier.SAI_FIC)
     
     
    SI ErreurDétectée = Vrai ALORS
    	Info("Insertion non éffectuée, réverifiez le code")
    	fFerme(IdFichierXLS)
     
    SINON
    	nBreLignes est un entier = xlsNbLigne(IdFichierXLS)
    	JAUGE_Jauge..BorneMin = 0
    	JAUGE_Jauge..BorneMax = nBreLignes
     
     
    	POUR i= 2 A nBreLignes
     
    			PositionLegacyID est un entier = xlsDonnée(IdFichierXLS,i,9)
     
     
    			SI 	PositionLegacyID = "" ALORS
    		    	PositionLegacyID = xlsDonnée(IdFichierXLS,i,10)
    		    	HLitRecherche(Transaction,Transaction.LegacyID,PositionLegacyID)
    		    	Transaction.LegacyID = PositionLegacyID
    		    SINON
    				PositionLegacyID = xlsDonnée(IdFichierXLS,i,9)
    				HLitRecherche(Transaction,Transaction.LegacyID,PositionLegacyID)			
    				TransDate est une Date = xlsDonnée(IdFichierXLS,i,1)
    				HLitRecherche(Transaction,Transaction.TransactionDate,TransDate)
    				TransID est un entier = xlsDonnée(IdFichierXLS,i,4)
    				HLitRecherche(Transaction,Transaction.IDTransaction,TransID)
    				nReference est un entier = xlsDonnée(IdFichierXLS,i,9)
    				HLitRecherche(Transaction,Transaction.Ref,nReference)
    				sProd1 est une chaîne = xlsDonnée(IdFichierXLS,i,12)
    				HLitRecherche(Transaction,Transaction.Prod,sProd1)
    				sTransactType est une chaîne = xlsDonnée(IdFichierXLS,i,13)
    				HLitRecherche(Transaction,Transaction.TranType,sTransactType)
    				sOrigContry est une chaîne = xlsDonnée(IdFichierXLS,i,15)
    				HLitRecherche(Transaction,Transaction.Orig_Country,sOrigContry)
    				sDestCountry est une chaîne = xlsDonnée(IdFichierXLS,i,16)
    				HLitRecherche(Transaction,Transaction.Rec_Country,sDestCountry)
    				rRate est un réel = xlsDonnée(IdFichierXLS,i,18)
    				HLitRecherche(Transaction,Transaction.Fx_Rate,rRate)
    				dFxDate est une Date = xlsDonnée(IdFichierXLS,i,25)
    				HLitRecherche(Transaction,Transaction.Fx_Date,dFxDate)
    				rMargin est un réel = xlsDonnée(IdFichierXLS,i,27)
    				HLitRecherche(Transaction,Transaction.Fx_Margin,rMargin)
    				rBAmount est un réel = xlsDonnée(IdFichierXLS,i,29)
    				HLitRecherche(Transaction,Transaction.Base_Amount,rBAmount)
    				rFAmount est un réel = xlsDonnée(IdFichierXLS,i,31)
    				HLitRecherche(Transaction,Transaction.Fee_Amount,rFAmount)
    				rSAmount est un réel = xlsDonnée(IdFichierXLS,i,33)
    				HLitRecherche(Transaction,Transaction.Share_Amount,rSAmount)
    				rCommAmount est un réel = xlsDonnée(IdFichierXLS,i,37)
    				HLitRecherche(Transaction,Transaction.Commision_Amount,rCommAmount)
    				rAccountTotal est un réel = xlsDonnée(IdFichierXLS,i,15)
     
    				SI rAccountTotal <> "" ALORS
    					HLitRecherche(Transaction,Transaction.AccountTotal,rAccountTotal)
     
    				SI PAS HTrouve(Transaction) ALORS
    				HRAZ(Transaction)
     
    					Transaction.LegacyID = PositionLegacyID
    					Transaction.TransactionDate = TransDate
    					Transaction.TransactionID = TransID
    					Transaction.Ref = nReference
    					Transaction.Prod = sProd1
    					Transaction.TranType = sTransactType
    					Transaction.Orig_Country = sOrigContry
    					Transaction.Rec_Country = sDestCountry
    					Transaction.Fx_Rate = rRate
    					Transaction.Fx_Date = dFxDate
    					Transaction.Fx_Margin = rMargin
    					Transaction.Base_Amount = rBAmount
    					Transaction.Fee_Amount = rFAmount
    					Transaction.Commision_Amount = rCommAmount
    					Transaction.AccountTotal = rAccountTotal
    					HAjoute(Transaction)
    				FIN
    			FIN
    		FIN	
     
    	FIN
    	Info ("Insertion éffectuée avec succès !!!!")
    	fFerme(IdFichierXLS)
    FIN
    "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.

  16. #16
    Expert éminent
    Avatar de frenchsting
    Homme Profil pro
    multitâches-multifonctions
    Inscrit en
    Juin 2003
    Messages
    5 207
    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 207
    Points : 9 208
    Points
    9 208
    Par défaut
    As tu exécuté ton code pas à pas pour connaître les valeurs que le programme lit ?

    tu fais des HLitRecherche(Transaction,xx,..) qui ne servent à rien puisque tu n'exploites pas le résultat de cette recherche. Tu peux donc les supprimer.

    De même ton code SI PositionLegacyID = "" ALORS ... est inutile. Il ne modifie aucune donnée, Seule la partie SINON pourra potentiellement modifier des données.
    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

  17. #17
    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,

    Le mode pas à pas marche bien, Quelques valeurs valeurs sont bien lu (un petit réaménagement de la boucle est nécessaire, parce qu'il existe des champs vides)

    Par contre, j'ai justement besoin du SI de PositionLegacyID, parce que ce champs peut être décaler parfois au suivant. Le checking est fait sur la valeur (si vide alors je prends celle du suivant) et elle modifie bien (Transaction.LegacyID = PositionLegacyID)

    Je vais enlever les différents HLitRecherche.
    "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.

  18. #18
    Expert éminent
    Avatar de frenchsting
    Homme Profil pro
    multitâches-multifonctions
    Inscrit en
    Juin 2003
    Messages
    5 207
    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 207
    Points : 9 208
    Points
    9 208
    Par défaut
    Je n'ai pas dit que ton test était inutile. J'ai dit que la partie alors ne sert à rien :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    PositionLegacyID = xlsDonnée(IdFichierXLS,i,10) // tu fais une lecure de données
    HLitRecherche(Transaction,Transaction.LegacyID,PositionLegacyID) // tu te positionnnes sur ton id de transaction (s'il existe, sinon c'est n'importe où)
    Transaction.LegacyID = PositionLegacyID // tu fais une affectation
    A partir d'ici, tu ne fais rien : ce traitement est donc inutile. Ton code devrait plutôt être :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    SI 	PositionLegacyID <> "" ALORS
    		PositionLegacyID = xlsDonnée(IdFichierXLS,i,9)...
    Et encore, je pourrais chipoter car PositionLegacyID = xlsDonnée(IdFichierXLS,i,9), tu l'as fais juste avant la condition.
    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

  19. #19
    Membre actif
    Homme Profil pro
    Développeur COBOL
    Inscrit en
    Mai 2015
    Messages
    138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur COBOL

    Informations forums :
    Inscription : Mai 2015
    Messages : 138
    Points : 270
    Points
    270
    Par défaut juste un detail
    Hello les amis

    je vois dans code que tu utilise fferme aves des instructions xls - remplace les par xlsferme - a mon avis c'est mieux - bon je pars une semaine en vacances j'espère
    que tu arriveras a résoudre ton problème a+ sinon je suis le fil et ne poste pas tant que je suis en accord avec frenchsting

  20. #20
    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 à tous,

    Excellentes vacances rudolfrudolf .

    Par contre moi, je me !

    Hier soir, j'ai essayé de repenser le code :

    - Après le xlsOuvre, je me positionne sur une ligne, en sachant bien que je connais la position de la valeur du champs Legacy_ID (qui est fixe généralement) et Account_Total que je récupère dans une table Agent; ensuite je parcours les transactions cet agent que je récupère dans la table Transaction.

    Pour faire court, je vous joint mes 2 fichiers (Excel que j'essaie de lire en ce moment, avec les noms des champs et leurs valeurs en surlignés) et aussi le texte en Input. FICHIER_ENTRE.txtFICHIER_ENTRE.xlsx

    Mon code suivant vos instructions :

    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    IdFichierXLS est un entier = xlsOuvre(SC_SelecteurFichier.SAI_FIC)
     
     
    SI ErreurDétectée = Vrai ALORS
    	Info("Insertion non éffectuée, réverifiez le code")
    	fFerme(IdFichierXLS)
     
    SINON
    	nBreLignes est un entier = xlsNbLigne(IdFichierXLS)
     
     
    	POUR i= 2 A nBreLignes
     
     
    		PositionLegacyID est un entier
     
    		SI 	PositionLegacyID <> "" ALORS
    			PositionLegacyID = xlsDonnée(IdFichierXLS,i,9)
    			EXPRESS_Agents.legacy_id = PositionLegacyID
    		SINON
    			PositionLegacyID = xlsDonnée(IdFichierXLS,i,10)			
    			dTransDateEXPRESS est une Date = xlsDonnée(IdFichierXLS,i,1)
    			nReference est un entier = xlsDonnée(IdFichierXLS,i,9)
    			sProd1 est une chaîne = xlsDonnée(IdFichierXLS,i,12)
    			sTransactTypeEXPRESS est une chaîne = xlsDonnée(IdFichierXLS,i,13)
    			sOrigContry est une chaîne = xlsDonnée(IdFichierXLS,i,15)
    			sDestCountry est une chaîne = xlsDonnée(IdFichierXLS,i,16)
    			rRate est un réel = xlsDonnée(IdFichierXLS,i,18)
    			dFxDateEXPRESS est une Date = xlsDonnée(IdFichierXLS,i,25)
    			rMargin est un réel = xlsDonnée(IdFichierXLS,i,27)
    			rBAmount est un réel = xlsDonnée(IdFichierXLS,i,29)
    			rFAmount est un réel = xlsDonnée(IdFichierXLS,i,31)
    			rSAmountEXPRESS est un réel = xlsDonnée(IdFichierXLS,i,33)
    			rCommAmountEXPRESS est un réel = xlsDonnée(IdFichierXLS,i,37)
     
    			rAccountTotal est un réel = xlsDonnée(IdFichierXLS,i,15)
     
    			SI rAccountTotal <> "" ALORS
    				  EXPRESS_Agents.account_total = rAccountTotal
    				SI PAS HTrouve(EXPRESS_Transaction) ALORS
    					HRAZ(EXPRESS_Transaction)
     
    					EXPRESS_Transaction.legacy_id = PositionLegacyID
    					EXPRESS_Transaction.transaction_date = dTransDateEXPRESS
    					EXPRESS_Transaction.ref = nReference
    					EXPRESS_Transaction.prod = sProd1
    					EXPRESS_Transaction.transaction_type = sTransactTypeEXPRESS
    					EXPRESS_Transaction.orig_country = sOrigContry
    					EXPRESS_Transaction.rec_country = sDestCountry
    					EXPRESS_Transaction.fx_rate = rRate
    					EXPRESS_Transaction.fx_dates = dFxDateEXPRESS
    					EXPRESS_Transaction.fx_margin = rMargin
    					EXPRESS_Transaction.base_amount = rBAmount
    					EXPRESS_Transaction.fee_amount = rFAmount
    					EXPRESS_Transaction.commission_amount = rCommAmountEXPRESS
    					HAjoute(EXPRESS_Transaction)
    				FIN
    			FIN
    		FIN	
     
    	FIN
    	Info ("Insertion éffectuée avec succès !!!!")
    	xlsFerme(IdFichierXLS)
    FIN
    "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.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Réponses: 13
    Dernier message: 23/09/2013, 04h21
  2. Réponses: 9
    Dernier message: 12/07/2011, 17h25
  3. Ecrire dans un fichier texte les entrées du clavier
    Par Manou1980 dans le forum Entrée/Sortie
    Réponses: 8
    Dernier message: 07/07/2011, 10h51
  4. Réponses: 2
    Dernier message: 10/02/2007, 12h07
  5. Réponses: 6
    Dernier message: 23/12/2003, 15h30

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