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
| Const ForReading = 1, ForWriting = 2
Dim oFso, f
Set oFso = CreateObject("Scripting.FileSystemObject")
Set f = oFso.OpenTextFile("C:\Users\Monique\Downloads\test.csv", ForReading)
ln=-1
cl=0
while Not f.AtEndOfStream '1ère itération pour définir les limites
ln=ln+1 'définition indice lignes
Tab=Split(f.ReadLine,";")
If cl < UBound(Tab) Then cl = UBound(Tab)
Wend
f.Close
MsgBox "indice lignes = " & ln & Vbcr & "indice colonnes = " & cl,64,"Information"
Dim Tab2()
ReDim Tab2(ln,cl)
Set f = oFso.OpenTextFile("C:\Users\Monique\Downloads\test.csv", ForReading)
i=0
while Not f.AtEndOfStream ' 2ème itération pour remplir le tableau
Tab = Split(f.ReadLine,";")
For j = 0 to UBound(Tab)
Tab2(i,j) = Tab(j)
Next
i=i+1
Wend
f.Close
Dim OutPut : OutPut = "OutPut_Resultat.txt"
Set f = oFso.OpenTextFile(OutPut,ForWriting,True)
Set ws = CreateObject("Wscript.Shell")
For i=0 to UBound(Tab2,1) ' vérification
For j=0 to UBound(Tab2,2)
f.WriteLine "La valeur de Tab2("&i&","&j&") ===> "& Tab2(i,j)
'MsgBox Tab2(i,j)
Next
Next
f.WriteLine VbNewline & "******************************************"
f.WriteLine "La valeur de Tab2(1,1) ===> "& Tab2(1,1)
ws.run "Notepad " & OutPut |
Partager