Bonsoir,


J' ai un fichier log qui se compose comme suit :


S:\SIRA-P~1\30-NEE~1\NE5AB8~1\DRAWD\CTRLNOTES7WSK_DRAWDF14.SUC.LOG
ligne vide
S:\SIRA-P~1\30-NEE~1\NE5AB8~1\DRAWD\CTRLNOTES7WSK_DRAWDP00.SUC.LOG
ligne vide
etc...

Sur ce fichier log j' ai cree une boucle pour récupérer la chaine DRAWDFxx.SUC sur chacune de ses lignes et réécrire un nouveau fichier log plus lisible.

Mon probleme est de savoir comment fait-on pour exclure les lignes vides qu' il y entre chaque ligne.

Dont voici le bout de code :

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
Const ForReading = 1,ForWriting = 2, ForAppending = 8
Dim ostRep 'Nom du repertoire a parcourir
Dim oFSO,oFl,of,f,objFSO,objFile
Dim strDirectory, strFile
Dim oLine,oMyArray,Chaine,oResultat
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
      ostRep = "c:\log"
      If oFSO.FolderExists(ostRep) Then
         For Each oFl In oFSO.GetFolder(ostRep).Files
          	'MsgBox oFl.Name
				oFileName = oFl.Name
					'Ouverture et lecture du fichier a  modifier...
			    	Set of = oFSO.OpenTextFile(ostRep & "\" & oFileName, ForReading)
			   		While Not of.AtEndOfStream 
                     oLine = of.ReadLine
						   'MsgBox oLine
							If oLine = "" Then 'J' ai essayer ceci mais ca pas l' air de fonctionner
							   'Do nothing
								Else
	                  	oMyArray = Split(oLine,"_")
								'MsgBox oMyArray(1)
								Chaine = oMyArray(1)
								oResultat = Split(Chaine,".")
								'MsgBox oResultat(0)
								'MsgBox oResultat(1)
								' Create the File System Object
								strDirectory = "c:\Log"
								strFile = "\NewLog.csv" 
								Set objFSO = CreateObject("Scripting.FileSystemObject")
                     	If Not objFSO.FileExists(strDirectory & strFile) Then
									Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
									ElseIf objFSO.FileExists(strDirectory & strFile) Then
										Set f = objFSO.OpenTextFile(strDirectory & strFile, ForWriting,True)	
										f.write(oResultat(0) & ";" & oResultat(1))
			   						f.Close
											Else
								   			MsgBox "Fichier inexistant"
								End If	
							End If
							'WScript.Quit
						Wend
			   	of.Close
			Next
   	End If
Merci d' avance pour vos réponses.


Cordialement.