Split complexe sur fichier texte
Bonjour,
Je me tourne vers vous car je sature à un haut point sur un parsing :oops:
j'ai un fichier text qui se présente sous la forme:
Code:
1 2 3 4
|
hostname, xxx | yyy | zzz
hostname2, xxx2 | yyy2 | zzz2 - xxx3 | yyy3 - xxx4 | yyy4 | zzz4
... |
Je dois en retirer un fichier qui se présentera sous la forme
Code:
1 2 3 4 5 6
|
hostname, yyyzzz
hostname2, yyy2zzz2
hostname2, yyy3
hostname2, yyy4zzz4
... |
J'arrive très bien à traiter les cas où je n'ai qu'un seul couple xxx | yyy | zzz mais dès que je passe à plus, je n'arrive plus à rien.
Voici mon code à l'heure actuelle:
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
|
Sub Parse_Txt_File(sTextFile)
Set objFso = CreateObject("Scripting.FileSystemObject")
Set F1 = objFso.OpenTextFile (sTextFile, 1)
Do Until F1.AtEndOfStream
Lit = F1.ReadLine
MyArrayComa = Split(Lit, ", ")
For i = 0 to UBound(MyArrayComa)
hostname = MyArrayComa(0)
appcompinstserver = MyArrayComa(1)
' WScript.Echo hostname & " " & appcompinstserver
MyArrayMinus = Split(appcompinstserver, " - ")
For j = 0 to UBound(MyArrayMinus)
If Ubound(MyArrayMinus) = 0 Then
appcompinst = MyArrayMinus(0)
MyArrayPipe = Split(appcompinst, " | ")
For k = 0 to UBound(MyArrayPipe)
If UBound(MyArrayPipe) < 2 Then
service = MyArrayPipe(1)
WScript.Echo hostname & ", " & service
Else
service = MyArrayPipe(1) & MyArrayPipe(2)
WScript.Echo hostname & ", " & service
End If
Next
' Else
'
End If
Next
Next
Loop
End Sub |
Oui c'est très lourd :cry: si quelqu'un à une petite idée je suis preneur, si besoin de plus amples explication, je fournirai :)
Cordialement