Lire deux fichiers en même temps
Bonjour
Je solicite votre aide
Je dois lire le fichier SYNTHESE.DAT ligne par ligne trouver l'imatriculation du vehicule et pour chaque Imatriculation du véhicule je dois trouver dans le fichier VEHICULE.DAT la ligne qui correspont a mon vehicule
Je pense que mon problème vient que j'utilise "ReadLine" dans mais 2 boucles mais je ne voi pas comment faire autrement
Structure du fichier SYNTHESE.DAT
1083TQ76;Gazole;167.54;1443;11.61;97849;
1150ZP76;Gazole;45.94;793;5.79;92800;
12AGR76;Gazole;395.60;4125;9.59;106748;
130TF76;Gazole;35.70;556;6.42;195188;
14AJF76;Gazole;71.11;1205;5.90;48771;
1581YH76;Gazole;168.85;2871;5.88;168150;
Structure du fichier VEHICULE.DAT
0000ZZ76;11290;TOURISME;D0 ROUEN;;;
1083TQ76;11204;SAV OUTILLAGE;D0ROUEN;TECHNICIENS;MASTER;RENAULT
1150ZP76;11378;SFR;D0 ROUEN;REPRESENTANTS;CLIO;RENAULT
12AGR76;11386;EXPEDITION;D0 ROUEN;LIVRAISON;TRANSIT;FORD
130TF76;11373;ATELIERS;D3 ST ETIENNE DU ROUVRAY NVI;ATELIER ELECTRICITÉ / CHRONO;CLIO;RENAULT
1379TQ76;11106;DIESEL;D0 ROUEN;TECHNICIENS;EXPERT;PEUGEOT
14AJF76;11420;SFR;D0 ROUEN;REPRESENTANTS;FIESTA;FORD
1581YH76;11254;COMMERCIAL;D3 ST ETIENNE DU ROUVRAY NVI;REPRESENTANTS;C3;CITROEN
15AJF76;11389;SFR;D0 ROUEN;REPRESENTANTS;FIESTA;FORD
Code:
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
| Const ForReading = 1, ForWriting = 2
Dim oFso, S, V
Dim constente1,constente2
Dim SFichier,ImatSFichier
Dim VFichier, ImatVFichier
Set oFso = CreateObject("Scripting.FileSystemObject")
Set S = oFso.OpenTextFile("c:\CONSO\SYNTHESE.DAT", ForReading)
Set V = oFso.OpenTextFile("c:\CONSO\VEHICULE.DAT", ForReading)
Set F = oFso.OpenTextFile("c:\CONSO\Fichier.csv", ForWriting,true)
while Not S.AtEndOfStream
constente1=S.ReadLine
SFichier = split(constente1,";")
ImatSFichier=SFichier(0)
do while V.AtEndOfStream=false
constente2 = V.ReadLine
VFichier = split(constente2,";")
ImatVFichier=VFichier(0)
If ImatSFichier=ImatVFichier then
Phrase=constente1 & ";" & constente2 & VbCrLf
End if
Loop
F.write(Phrase)
Wend
S.Close
V.Close
F.Close |
Merci de votre aide:ccool: