bonjour
j ai trouver ce code sur le net pour lire un fichier csv
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
Set FSO = CreateObject("Scripting.FileSystemObject") 
Set Ftxt = FSO.OpenTextFile("e:\ScanReseaux.csv") 
 
Do While Not Ftxt.AtEndOfStream  
MaVariable = Ftxt.Readline  
 
For Each strItem In CSVParse(mavariable) 
'    wscript.Echo strItem ' affiche le contenu du fichier csv, champs apres champs ... 
'... inserer le code ici 
 
	MsgBox stritem
 
 
Next 
Loop 
Ftxt.Close 
 
Function CSVParse(ByVal strLine) 
    Dim arrFields 
    Dim blnIgnore 
    Dim intFieldCount 
    Dim intCursor 
    Dim intStart 
    Dim strChar 
    Dim strValue 
 
    Const QUOTE = """" 
    Const QUOTE2 = """""" 
 
    If (Len(Trim(strLine)) = 0) then 
        CSVParse = Array() 
        Exit Function 
    End If 
    blnIgnore = False 
    intFieldCount = 0 
    intStart = 1 
    arrFields = Array() 
    strLine = strLine & "," 
 
    For intCursor = 1 To Len(strLine) 
 
        strChar = Mid(strLine, intCursor, 1) 
        Select Case strChar 
            Case QUOTE 
 
                blnIgnore = Not blnIgnore 
            Case "," 
                If Not blnIgnore Then 
 
                    ReDim Preserve arrFields(intFieldCount) 
 
                    If (intCursor - intStart > 0) Then 
 
                        strValue = Mid(strLine, intStart, _ 
                            intCursor - intStart) 
 
                        If (Left(strValue, 1) = QUOTE) Then 
                            arrFields(intFieldCount) = _ 
                                Replace(Mid(strValue, 2, _ 
                                Len(strValue) - 2), QUOTE2, QUOTE) 
                        Else 
                            arrFields(intFieldCount) = strValue 
                        End If 
                    Else 
                        arrFields(intFieldCount) = Empty 
                    End If 
 
                    intFieldCount = intFieldCount + 1 
                    intStart = intCursor + 1 
                End If 
        End Select 
    Next 
      CSVParse = arrFields 
End Function
j aimerais savoir comment faire pour inserer chaque champ dans une champ de tableau afin de pouvoir ensuite generer une liste deroulant dans un module hta avec un des champ
merci d avance