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

Python Discussion :

Transformation xml en csv [Python 3.X]


Sujet :

Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Pôle Etude et Automatisation
    Inscrit en
    Avril 2007
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Pôle Etude et Automatisation
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2007
    Messages : 166
    Par défaut Transformation xml en csv
    Bonjour,

    je n'arrive pas à transformer mon fichier xml en csv.

    Pouvez vous m'aider SVP?

    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
     
    #Lecture du fichier xml
     
    f = open("xml2.xml", "r")
     
    # Détermine le nombre de lignes dans le fichier
     
    NombredeLigne = 0
     
    for line in f:
     
        NombredeLigne += 1
     
    # Revient au début du fichier après avoir déterminer le nombre de lignes
     
    f.seek(0)
     
    # Détermine le nombre de champs par ligne
     
    data = f.read()
     
    lines = data.splitlines()
     
    i = 0
     
    NombreChampsParLigne = 0
     
    for line in enumerate(lines) :
     
        s = lines[i]
     
        if s.startswith("<FixedColumn>") :
     
            NombreChampsParLigne += 1
     
            i += 1
     
        i += 1
     
        if i >= NombredeLigne :
     
            break
     
    f.closed
    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
    86
    87
    88
    89
    90
     
    #!/usr/bin/env python
    # -*-coding: utf-8 -*
     
    entetes = [
         'Name',
         'Description',
         'DataType',
         'Format',
         'From',
         'To'
    ]
     
    t = []
    valeurs = []
    w = ""
     
     
    i = 0
    debut = ""
     
    for line in enumerate(lines):
     
        s = lines[i]
     
        if s.startswith("<FixedColumn>") :
            debut = "OK"
     
        if debut == "OK":  
     
            if s.startswith("<Name>") :
                s = s.replace("<Name>", "")
                s = s.replace("</Name>","")
                t.append(s)       
     
            if s.startswith("<Description>") :
                s = s.replace("<Description>", "")
                s = s.replace("</Description>","")
                t.append(s)
     
            if s.startswith("<AlphaNumeric/>") :
                s = s.replace("<AlphaNumeric/>", "AlphaNumeric")
                verifFormat = "no"
                t.append(s)
                w = "NaN"
                t.append(w)
     
            if s.startswith("<Numeric>") :
                s = s.replace("<Numeric>", "Numeric")
                verifFormat = "no"
                t.append(s)
                w = "NaN"
                t.append(w)
     
            if s.startswith("<Date>") :
                s = s.replace("<Date>", "Date")
                t.append(s)
                verifFormat = "yes"
     
            if s.startswith("<Format>") and verifFormat == "yes":
                s = s.replace("<Format>", "")
                s = s.replace("</Format>","")
                verifFormat = "no"
                t.append(s)
     
            if s.startswith("<From>") :
                s = s.replace("<From>", "")
                s = s.replace("</From>","")
                t.append(s)
     
            if s.startswith("<To>") :
                s = s.replace("<To>", "")
                s = s.replace("</To>","")
                t.append(s)
     
     
        i += 1
     
    valeurs.append(t)    
     
    print (t)
     
    f = open('monFichier.csv', 'w')
    ligneEntete = ";".join(entetes) + "\n"
    f.write(ligneEntete)
    for valeur in valeurs:
         ligne = ";".join(valeur) + "\n"
         f.write(ligne)
     
    f.close()
    Merci
    Eric
    Fichiers attachés Fichiers attachés

  2. #2
    Expert éminent
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 741
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 741
    Par défaut
    Salut,

    Pour lire un fichier XML et en extraire les données sans trop se prendre la tête, il faut apprendre à utiliser une bibliothèque qui le fait.
    En standard vous avez xml.etree.ElementTree.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  3. #3
    Membre confirmé
    Profil pro
    Pôle Etude et Automatisation
    Inscrit en
    Avril 2007
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Pôle Etude et Automatisation
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2007
    Messages : 166
    Par défaut
    Bonjour,

    J'ai fait des progrès mais cela ne suffit pas. Je n'arrive pas aux éléments des sous listes.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    def createList(name, n):
        result = {}
        for i in range(n):
            nameList = name + str(i)
            result[nameList] = []
        return result
    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
     
    #Lecture du fichier xml
     
    f = open("xml2.xml", "r")
     
    # Détermine le nombre de lignes dans le fichier
     
    NombredeLigne = 0
     
    for line in f:
     
        NombredeLigne += 1
     
    # Revient au début du fichier après avoir déterminer le nombre de lignes
    print(NombredeLigne)
    f.seek(0)
     
    # Détermine le nombre de champs par ligne
     
    data = f.read()
     
    lines = data.splitlines()
     
    i = 0
     
    NombreChampsParLigne = 0
     
    for line in enumerate(lines) :
     
        s = lines[i]
     
        if s.startswith("<FixedColumn>") :
     
            NombreChampsParLigne += 1
     
            i += 1
     
        i += 1
     
        if i >= NombredeLigne :
     
            break
     
    print (NombreChampsParLigne)
     
    res = createList("list", NombreChampsParLigne) # création de 5 listes dont le nom commence par list
     
    print(res)
     
    f.closed
    output:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    1130
    115
    {'list0': [], 'list1': [], 'list2': [], 'list3': [], 'list4': [], 'list5': [], 'list6': [], 'list7': [], 'list8': [], 'list9': [], 'list10': [], 'list11': [], 'list12': [], 'list13': [], 'list14': [], 'list15': [], 'list16': [], 'list17': [], 'list18': [], 'list19': [], 'list20': [], 'list21': [], 'list22': [], 'list23': [], 'list24': [], 'list25': [], 'list26': [], 'list27': [], 'list28': [], 'list29': [], 'list30': [], 'list31': [], 'list32': [], 'list33': [], 'list34': [], 'list35': [], 'list36': [], 'list37': [], 'list38': [], 'list39': [], 'list40': [], 'list41': [], 'list42': [], 'list43': [], 'list44': [], 'list45': [], 'list46': [], 'list47': [], 'list48': [], 'list49': [], 'list50': [], 'list51': [], 'list52': [], 'list53': [], 'list54': [], 'list55': [], 'list56': [], 'list57': [], 'list58': [], 'list59': [], 'list60': [], 'list61': [], 'list62': [], 'list63': [], 'list64': [], 'list65': [], 'list66': [], 'list67': [], 'list68': [], 'list69': [], 'list70': [], 'list71': [], 'list72': [], 'list73': [], 'list74': [], 'list75': [], 'list76': [], 'list77': [], 'list78': [], 'list79': [], 'list80': [], 'list81': [], 'list82': [], 'list83': [], 'list84': [], 'list85': [], 'list86': [], 'list87': [], 'list88': [], 'list89': [], 'list90': [], 'list91': [], 'list92': [], 'list93': [], 'list94': [], 'list95': [], 'list96': [], 'list97': [], 'list98': [], 'list99': [], 'list100': [], 'list101': [], 'list102': [], 'list103': [], 'list104': [], 'list105': [], 'list106': [], 'list107': [], 'list108': [], 'list109': [], 'list110': [], 'list111': [], 'list112': [], 'list113': [], 'list114': []}
     
    False
    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
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
     
    #!/usr/bin/env python
    # -*-coding: utf-8 -*
     
    entetes = [
         'Name',
         'Description',
         'DataType',
         'Format',
         'From',
         'To'
    ]
     
    t = []
    #valeurs = []
    w = ""
     
     
    i = 0
    j = -1
     
    debut = ""
     
    for line in enumerate(lines):
     
        s = lines[i]
     
        if s.startswith("<FixedColumn>") :
            debut = "OK"
            j += 1
     
        if debut == "OK":  
     
            if s.startswith("<Name>") :
                s = s.replace("<Name>", "")
                s = s.replace("</Name>","")
                t.append(s)
     
            if s.startswith("<Description>") :
                s = s.replace("<Description>", "")
                s = s.replace("</Description>","")
                t.append(s)
     
            if s.startswith("<AlphaNumeric/>") :
                s = s.replace("<AlphaNumeric/>", "AlphaNumeric")
                verifFormat = "no"
                t.append(s)
                w = "NaN"
                t.append(w)
     
            if s.startswith("<Numeric>") :
                s = s.replace("<Numeric>", "Numeric")
                verifFormat = "no"
                t.append(s)
                w = "NaN"
                t.append(w)
     
            if s.startswith("<Date>") :
                s = s.replace("<Date>", "Date")
                t.append(s)
                verifFormat = "yes"
     
            if s.startswith("<Format>") and verifFormat == "yes":
                s = s.replace("<Format>", "")
                s = s.replace("</Format>","")
                verifFormat = "no"
                t.append(s)
     
            if s.startswith("<From>") :
                s = s.replace("<From>", "")
                s = s.replace("</From>","")
                t.append(s)
     
            if s.startswith("<To>") :
                s = s.replace("<To>", "")
                s = s.replace("</To>","")
                t.append(s)      
                valList = "list" + str(j)       
                res[valList].extend(t) # on ajoute les valeurs à list i
                del t[:]
     
        i += 1
     
     
    print('*********')
    print(entetes)
    print('*********') 
    print('*********')
    print(res)
    print('*********')    
     
     
    f = open('monFichier.csv', 'w')
     
    ligneEntete = ";".join(entetes) + "\n"
    f.write(ligneEntete)
    ligneValeur = ";".join(res) + "\n"
    f.write(ligneValeur)
     
    f.close()
    output

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    *********
    ['Name', 'Description', 'DataType', 'Format', 'From', 'To']
    *********
    *********
    {'list0': ['BKPF-BUKRS', 'Company Code', 'AlphaNumeric', 'NaN', '1', '4'], 'list1': ['BKPF-BELNR', 'Accounting Document Number', 'AlphaNumeric', 'NaN', '5', '14'], 'list2': ['BKPF-GJAHR', 'Fiscal Year', 'Numeric', 'NaN', '15', '18'], 'list3': ['BKPF-BLART', 'Document Type', 'AlphaNumeric', 'NaN', '19', '20'], 'list4': ['BKPF-BLDAT', 'Document Date in Document', 'Date', 'YYYYMMDD', '21', '28'], 'list5': ['BKPF-BUDAT', 'Posting Date in the Document', 'Date', 'YYYYMMDD', '29', '36'], 'list6': ['BKPF-MONAT', 'Fiscal Period', 'Numeric', 'NaN', '37', '38'], 'list7': ['BKPF-CPUDT', 'Day On Which Accounting Document Was Entered', 'Date', 'YYYYMMDD', '39', '46'], 'list8': ['BKPF-CPUTM', 'Time of Entry', 'AlphaNumeric', 'NaN', '47', '52'], 'list9': ['BKPF-AEDAT', 'Date of the Last Document Change by Transaction', 'Date', 'YYYYMMDD', '53', '60'], 'list10': ['BKPF-UPDDT', 'Date of the Last Document Update', 'Date', 'YYYYMMDD', '61', '68'], 'list11': ['BKPF-USNAM', 'User name', 'AlphaNumeric', 'NaN', '69', '80'], 'list12': ['BKPF-TCODE', 'Transaction Code', 'AlphaNumeric', 'NaN', '81', '100'], 'list13': ['BKPF-BVORG', 'Number of Cross-Company Code Posting Transaction', 'AlphaNumeric', 'NaN', '101', '116'], 'list14': ['BKPF-XBLNR', 'Reference Document Number', 'AlphaNumeric', 'NaN', '117', '132'], 'list15': ['BKPF-DBBLG', 'Recurring Entry Document Number', 'AlphaNumeric', 'NaN', '133', '142'], 'list16': ['BKPF-STBLG', 'Reverse Document Number', 'AlphaNumeric', 'NaN', '143', '152'], 'list17': ['BKPF-STJAH', 'Reverse document fiscal year', 'Numeric', 'NaN', '153', '156'], 'list18': ['BKPF-BKTXT', 'Document Header Text', 'AlphaNumeric', 'NaN', '157', '181'], 'list19': ['BKPF-XRUEB', 'Indicator: Document is posted to a previous period', 'AlphaNumeric', 'NaN', '182', '182'], 'list20': ['BKPF-AWTYP', 'Reference Transaction', 'AlphaNumeric', 'NaN', '183', '187'], 'list21': ['BKPF-AWKEY', 'Reference Key', 'AlphaNumeric', 'NaN', '188', '207'], 'list22': ['BKPF-FIKRS', 'Financial Management Area', 'AlphaNumeric', 'NaN', '208', '211'], 'list23': ['BKPF-XSTOV', 'Indicator: Document is flagged for reversal', 'AlphaNumeric', 'NaN', '212', '212'], 'list24': ['BKPF-AWSYS', 'Logical System', 'AlphaNumeric', 'NaN', '213', '222'], 'list25': ['BKPF-PPNAM', 'Name of User Who Parked this Document', 'AlphaNumeric', 'NaN', '223', '234'], 'list26': ['BKPF-XREF1_HD', 'Reference Key 1 Internal for Document Header', 'AlphaNumeric', 'NaN', '235', '254'], 'list27': ['BKPF-XREF2_HD', 'Reference Key 2 Internal for Document Header', 'AlphaNumeric', 'NaN', '255', '274'], 'list28': ['BKPF-XREVERSAL', 'Specifies whether doc. is reversal doc. or reversed doc.', 'AlphaNumeric', 'NaN', '275', '275'], 'list29': ['BKPF-REINDAT', 'Invoice Receipt Date', 'Date', 'YYYYMMDD', '276', '283'], 'list30': ['BKPF-INTDATE', 'Interest Calc. Date', 'Date', 'YYYYMMDD', '284', '291'], 'list31': ['BKPF-PSOBT', 'Posting Day', 'Date', 'YYYYMMDD', '292', '299'], 'list32': ['BKPF-SNAME', 'User Name', 'AlphaNumeric', 'NaN', '300', '311'], 'list33': ['BKPF-ZZ_CODLIB', '', 'AlphaNumeric', 'NaN', '312', '313'], 'list34': ['BKPF-ZZ_TXTLIB', '', 'AlphaNumeric', 'NaN', '314', '373'], 'list35': ['BKPF-ZZ_AMG', '', 'AlphaNumeric', 'NaN', '374', '379'], 'list36': ['BKPF-ZZ_NUMTITRE', '', 'AlphaNumeric', 'NaN', '380', '419'], 'list37': ['BKPF-ZZ_MARQUEUR', "Marqueur piste d'audit FIGL sous forme texte (UUID)", 'AlphaNumeric', 'NaN', '420', '451'], 'list38': ['BSIS-BUKRS', 'Company Code', 'AlphaNumeric', 'NaN', '452', '455'], 'list39': ['BSIS-HKONT', 'General Ledger Account', 'AlphaNumeric', 'NaN', '456', '465'], 'list40': ['BSIS-AUGDT', 'Clearing Date', 'Date', 'YYYYMMDD', '466', '473'], 'list41': ['BSIS-AUGBL', 'Document Number of the Clearing Document', 'AlphaNumeric', 'NaN', '474', '483'], 'list42': ['BSIS-ZUONR', 'Assignment Number', 'AlphaNumeric', 'NaN', '484', '501'], 'list43': ['BSIS-GJAHR', 'Fiscal Year', 'Numeric', 'NaN', '502', '505'], 'list44': ['BSIS-BELNR', 'Accounting Document Number', 'AlphaNumeric', 'NaN', '506', '515'], 'list45': ['BSIS-BUZEI', 'Number of Line Item Within Accounting Document', 'Numeric', 'NaN', '516', '518'], 'list46': ['BSIS-BUDAT', 'Posting Date in the Document', 'Date', 'YYYYMMDD', '519', '526'], 'list47': ['BSIS-BLDAT', 'Document Date in Document', 'Date', 'YYYYMMDD', '527', '534'], 'list48': ['BSIS-WAERS', 'Currency Key', 'AlphaNumeric', 'NaN', '535', '539'], 'list49': ['BSIS-XBLNR', 'Reference Document Number', 'AlphaNumeric', 'NaN', '540', '555'], 'list50': ['BSIS-BLART', 'Document Type', 'AlphaNumeric', 'NaN', '556', '557'], 'list51': ['BSIS-MONAT', 'Fiscal Period', 'Numeric', 'NaN', '558', '559'], 'list52': ['BSIS-BSCHL', 'Posting Key', 'AlphaNumeric', 'NaN', '560', '561'], 'list53': ['BSIS-SHKZG', 'Debit/Credit Indicator', 'AlphaNumeric', 'NaN', '562', '562'], 'list54': ['BSIS-GSBER', 'Business Area', 'AlphaNumeric', 'NaN', '563', '566'], 'list55': ['BSIS-MWSKZ', 'Tax on sales/purchases code', 'AlphaNumeric', 'NaN', '567', '568'], 'list56': ['BSIS-FKONT', 'Financial Budget Item', 'Numeric', 'NaN', '569', '571'], 'list57': ['BSIS-DMBTR', 'Amount in Local Currency', 'Numeric', 'NaN', '572', '586'], 'list58': ['BSIS-WRBTR', 'Amount in document currency', 'Numeric', 'NaN', '587', '601'], 'list59': ['BSIS-MWSTS', 'Tax Amount in Local Currency', 'Numeric', 'NaN', '602', '616'], 'list60': ['BSIS-WMWST', 'Tax amount in document currency', 'Numeric', 'NaN', '617', '631'], 'list61': ['BSIS-SGTXT', 'Item Text', 'AlphaNumeric', 'NaN', '632', '681'], 'list62': ['BSIS-PROJN', 'Old: Project number : No longer used --&gt; PS_POSNR', 'AlphaNumeric', 'NaN', '682', '697'], 'list63': ['BSIS-AUFNR', 'Order Number', 'AlphaNumeric', 'NaN', '698', '709'], 'list64': ['BSIS-WERKS', 'Plant', 'AlphaNumeric', 'NaN', '710', '713'], 'list65': ['BSIS-KOSTL', 'Cost Center', 'AlphaNumeric', 'NaN', '714', '723'], 'list66': ['BSIS-ZFBDT', 'Baseline Date for Due Date Calculation', 'Date', 'YYYYMMDD', '724', '731'], 'list67': ['BSIS-XOPVW', 'Indicator: Open Item Management?', 'AlphaNumeric', 'NaN', '732', '732'], 'list68': ['BSIS-VALUT', 'Value date', 'Date', 'YYYYMMDD', '733', '740'], 'list69': ['BSIS-BSTAT', 'Document Status', 'AlphaNumeric', 'NaN', '741', '741'], 'list70': ['BSIS-BDIFF', 'Valuation Difference', 'Numeric', 'NaN', '742', '756'], 'list71': ['BSIS-BDIF2', 'Valuation Difference for the Second Local Currency', 'Numeric', 'NaN', '757', '771'], 'list72': ['BSIS-VBUND', 'Company ID of trading partner', 'AlphaNumeric', 'NaN', '772', '777'], 'list73': ['BSIS-PSWSL', 'Update Currency for General Ledger Transaction Figures', 'AlphaNumeric', 'NaN', '778', '782'], 'list74': ['BSIS-WVERW', 'Bill of exchange usage type', 'AlphaNumeric', 'NaN', '783', '783'], 'list75': ['BSIS-DMBE2', 'Amount in Second Local Currency', 'Numeric', 'NaN', '784', '798'], 'list76': ['BSIS-DMBE3', 'Amount in Third Local Currency', 'Numeric', 'NaN', '799', '813'], 'list77': ['BSIS-MWST2', 'Tax Amount in Second Local Currency', 'Numeric', 'NaN', '814', '828'], 'list78': ['BSIS-MWST3', 'Tax Amount in Third Local Currency', 'Numeric', 'NaN', '829', '843'], 'list79': ['BSIS-BDIF3', 'Valuation Difference for the Third Local Currency', 'Numeric', 'NaN', '844', '858'], 'list80': ['BSIS-RDIF3', 'Exchange Rate Difference Realized for Third Local Currency', 'Numeric', 'NaN', '859', '873'], 'list81': ['BSIS-XRAGL', 'Indicator: Clearing was Reversed', 'AlphaNumeric', 'NaN', '874', '874'], 'list82': ['BSIS-PROJK', 'Work Breakdown Structure Element (WBS Element)', 'Numeric', 'NaN', '875', '882'], 'list83': ['BSIS-PRCTR', 'Profit Center', 'AlphaNumeric', 'NaN', '883', '892'], 'list84': ['BSIS-XSTOV', 'Indicator: Document is flagged for reversal', 'AlphaNumeric', 'NaN', '893', '893'], 'list85': ['BSIS-XARCH', 'Indicator: Document already archived ?', 'AlphaNumeric', 'NaN', '894', '894'], 'list86': ['BSIS-PSWBT', 'Amount for Updating in General Ledger', 'Numeric', 'NaN', '895', '909'], 'list87': ['BSIS-XNEGP', 'Indicator: Negative posting', 'AlphaNumeric', 'NaN', '910', '910'], 'list88': ['BSIS-RFZEI', 'Payment Card Item', 'Numeric', 'NaN', '911', '913'], 'list89': ['BSIS-CCBTC', 'Payment cards: Settlement run', 'AlphaNumeric', 'NaN', '914', '923'], 'list90': ['BSIS-XREF3', 'Reference key for line item', 'AlphaNumeric', 'NaN', '924', '943'], 'list91': ['BSIS-BUPLA', 'Business Place', 'AlphaNumeric', 'NaN', '944', '947'], 'list92': ['BSIS-PPDIFF', 'Realized Exchange Rate Gain/Loss 1.Loc.Curr.(Part Payments)', 'Numeric', 'NaN', '948', '962'], 'list93': ['BSIS-PPDIF2', 'Realized Exchange Rate Gain/Loss 2.Loc. Curr.(Part Payments)', 'Numeric', 'NaN', '963', '977'], 'list94': ['BSIS-PPDIF3', 'Realized Exchange Rate Gain/Loss 3.Loc.Curr.(Part Payments)', 'Numeric', 'NaN', '978', '992'], 'list95': ['BSIS-BEWAR', 'Transaction Type', 'AlphaNumeric', 'NaN', '993', '995'], 'list96': ['BSIS-IMKEY', 'Internal Key for Real Estate Object', 'AlphaNumeric', 'NaN', '996', '1003'], 'list97': ['BSIS-DABRZ', 'Reference Date for Settlement', 'Date', 'YYYYMMDD', '1004', '1011'], 'list98': ['BSIS-INTRENO', 'Internal Real Estate Master Data Code', 'AlphaNumeric', 'NaN', '1012', '1024'], 'list99': ['BSIS-GRANT_NBR', 'Grant', 'AlphaNumeric', 'NaN', '1025', '1044'], 'list100': ['BSIS-FKBER', 'Functional Area', 'AlphaNumeric', 'NaN', '1045', '1060'], 'list101': ['BSIS-FIPOS', 'Commitment Item', 'AlphaNumeric', 'NaN', '1061', '1074'], 'list102': ['BSIS-FISTL', 'Funds Center', 'AlphaNumeric', 'NaN', '1075', '1090'], 'list103': ['BSIS-GEBER', 'Fund', 'AlphaNumeric', 'NaN', '1091', '1100'], 'list104': ['BSIS-PPRCT', 'Partner Profit Center', 'AlphaNumeric', 'NaN', '1101', '1110'], 'list105': ['BSIS-BUZID', 'Identification of the Line Item', 'AlphaNumeric', 'NaN', '1111', '1111'], 'list106': ['BSIS-AUGGJ', 'Fiscal Year of Clearing Document', 'Numeric', 'NaN', '1112', '1115'], 'list107': ['BSIS-UZAWE', 'Payment Method Supplement', 'AlphaNumeric', 'NaN', '1116', '1117'], 'list108': ['BSIS-SEGMENT', 'Segment for Segmental Reporting', 'AlphaNumeric', 'NaN', '1118', '1127'], 'list109': ['BSIS-PSEGMENT', 'Partner Segment for Segmental Reporting', 'AlphaNumeric', 'NaN', '1128', '1137'], 'list110': ['BSIS-FIPEX', 'Commitment item - Do not use field - see note 447805', 'AlphaNumeric', 'NaN', '1138', '1161'], 'list111': ['BSIS-PRODPER', '', 'AlphaNumeric', 'NaN', '1162', '1167'], 'list112': ['BSIS-QSSKZ', 'Withholding Tax Code', 'AlphaNumeric', 'NaN', '1168', '1169'], 'list113': ['BSIS-PROPMANO', 'Mandate, Mandate-Opening Contract', 'AlphaNumeric', 'NaN', '1170', '1182'], 'list114': ['SKB1-XOPVW', 'Indicator: Open Item Management?', 'AlphaNumeric', 'NaN', '1183', '1183']}
    *********
    Je souhaiterai insérer le détail des listes exemple sur la list0

    'list0': ['BKPF-BUKRS', 'Company Code', 'AlphaNumeric', 'NaN', '1', '4']

    dans mon classeur csv
    1 colonne => BKPF-BUKRS
    2 colonne => Company Code
    3 colonne => AlphaNumeric
    4 colonne => NaN
    5 colonne => 1
    6 colonne => 4

    et cela jusqu'à la list114

    Merci

    Eric

  4. #4
    Membre confirmé
    Profil pro
    Pôle Etude et Automatisation
    Inscrit en
    Avril 2007
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Pôle Etude et Automatisation
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2007
    Messages : 166
    Par défaut
    Solution apportée par Fangh sur UCA Python 3 : des fondamentaux aux concepts avancés du langage

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    import pandas as pd
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    datas = res
    my_dataframe = pd.DataFrame.from_dict(datas, orient='index')
    print(my_dataframe)
    Merci à tous
    Eric

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

Discussions similaires

  1. Transformation XML en CSV, problème indentation
    Par Max1000p dans le forum XML/XSL et SOAP
    Réponses: 5
    Dernier message: 08/06/2012, 21h28
  2. Faisabilité transformation XSL pour CSV -> XML?
    Par H1B4K dans le forum XSL/XSLT/XPATH
    Réponses: 5
    Dernier message: 01/08/2011, 16h39
  3. Réponses: 0
    Dernier message: 29/06/2009, 11h09
  4. sed et awk pour transformation d'un fichier XML en CSV
    Par bstages2000 dans le forum Linux
    Réponses: 4
    Dernier message: 02/03/2008, 17h19
  5. [XML][CSV]Transformer du XML en CSV et inversement !
    Par tgarcia dans le forum XML/XSL et SOAP
    Réponses: 6
    Dernier message: 20/11/2006, 16h10

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