Ranger un fichier log

Bouzoul Messages postés 5 Date d'inscription dimanche 20 juillet 2003 Statut Membre Dernière intervention 8 avril 2004 - 27 nov. 2003 à 13:04
Bouzoul Messages postés 5 Date d'inscription dimanche 20 juillet 2003 Statut Membre Dernière intervention 8 avril 2004 - 27 nov. 2003 à 15:13
Salut,

Je voudrais ranger un fichier log de type :

81.81.81.81
host distant:"AParis.wanandoo.fr" Heure:"16H15"
C:\= 9.99 GB Total / 3.81 GB Free
D:\= 9.99 GB Total / 6.92 GB Free
E:\= 17.25 GB Total / 4.82 GB Free

81.81.81.81
host distant:"AParis.wanandoo.fr" Heure:"16H15"
C:\= 9.99 GB Total / 3.81 GB Free
D:\= 9.99 GB Total / 6.92 GB Free
E:\= 17.25 GB Total / 4.82 GB Free

etc.....

et je voudrais transformer ce log dans un fichier txt comme cela :

81.81.81.8 AParis.wanandoo.fr 16H15

81.81.81.8 AParis.wanandoo.fr 16H15

qqun pourrait m'aider a coder cela paske je cale là :-/

merci d'avance

3 réponses

pcpunch Messages postés 1243 Date d'inscription mardi 7 mai 2002 Statut Membre Dernière intervention 18 février 2019 5
27 nov. 2003 à 14:40
Voila !!!

Private Sub Command1_Click()
Dim Ligne As String
Dim Temp As String
Dim Position
Dim Position2
Open "c:\log.txt" For Input As #1
Open "c:\fichier.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, Ligne
If IsNumeric(Left(Ligne, 1)) Then Temp = Ligne
Position = InStr(1, Ligne, Chr(34))
If Position <> 0 Then
Position2 = InStr(Position + 1, Ligne, Chr(34))
Temp = Temp & " " & Mid(Ligne, Position + 1, Position2 - Position - 1)
Position = InStr(Position2 + 1, Ligne, Chr(34))
Position2 = InStr(Position + 1, Ligne, Chr(34))
Temp = Temp & " " & Mid(Ligne, Position + 1, Position2 - Position - 1)
Print #2, Temp
End If
Loop
Close #1
Close #2
End Sub
0
pcpunch Messages postés 1243 Date d'inscription mardi 7 mai 2002 Statut Membre Dernière intervention 18 février 2019 5
27 nov. 2003 à 14:47
Fait en 5Mn peu etre pas optimisé a fond, mais ca marche!!!
0
Bouzoul Messages postés 5 Date d'inscription dimanche 20 juillet 2003 Statut Membre Dernière intervention 8 avril 2004
27 nov. 2003 à 15:13
super sympa de ta part! merci je testes ça de suite !!!
0
Rejoignez-nous