Bonsoir,
Après plusieurs heures de recherches j'ai enfin trouvé le fichier dans le sous-dossier !
Maintenant je veux lire ce fichier et le transférer danss une bas de données Sqlserver.
Première question : ce fichier est lisble en xml ?
Moi j'ai une réponse ... none
Voici mon 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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 <?xml version="1.0" encoding ="UTF-8" standalone="no"?> <db_achilles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Y:\DCIP\DataAchilles\Export\Tables\AchillesDBSchema.xsd" created="2017-12-22T10:34:24" dataherr="VD140"> <Patient records="54000"> <record> <PatientNr>685362</PatientNr> <Lastname>AAOUIDA</Lastname> <Firstname>Samira</Firstname> <AHVNr></AHVNr> <Male>false</Male> <DateOfBirth>1976-08-10</DateOfBirth> <Profession></Profession> <Field1>Maroc</Field1> <Field2>AC</Field2> <Field3>Aigle</Field3> <Field4>Célibataire</Field4> <Field5>Sans permis</Field5> <Remark>Assurance: sans assurance£DateModif: 25.08.2017£DateCreation: 07.03.2008£</Remark> <VeKaLastUpdate xsi:nil="true" /> <CustomerType></CustomerType> <AddressNr>284</AddressNr> <ImportantInfo></ImportantInfo> <ImportantInfoOpen>false</ImportantInfoOpen> <Barcode>ÌÊPÇdU^bÎ</Barcode> <IncoiceCopy>false</IncoiceCopy> <ZPModified>0</ZPModified> <ZPDataOwner></ZPDataOwner> <Passive>false</Passive> <PassiveToken></PassiveToken> <PassiveReasonOfDeath></PassiveReasonOfDeath> <PassiveDate xsi:nil="true" /> <Death>false</Death> <DeathToken></DeathToken> <DateOfDeath xsi:nil="true" /> </record>
Merci de bien vouloir m'aider sur ce sujet ...
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 import glob import os.path import xml.etree.cElementTree as ET os.chdir('/Users/gmull/Documents/Python/Tables') sPath = os.getcwd() for filename in glob.iglob('/Users/gmull/Documents/Python/Tables/**/Patient*.xml', recursive=True): tree = ET.ElementTree(file=filename) root = tree.getroot() for child in root: print( child.get('PatientNr'))
Belle soirée
Muller Guy
Partager