Bonjour,

Mon problème je crois q'il sera simple à résoudre :

J'ai un script :

Première portion de code (variables et fonctions)

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
 
 
Function Add0(nb)
    If CInt(nb) < 10 Then
        nb = "0" & CStr(nb)
    End If
    Add0 = nb
End Function
 
' This function trims the string to the next ";" Ex: "1;2;3" becomes "2;3"
' Variable iCell is used to keep track of the current cell
Function NextCsvCell(ByRef iCell,TxtLine)
    iCell = iCell + 1
    iPos = InStr(TxtLine,";")
    TxtLine = Right(TxtLine,Len(TxtLine) - iPos)
    NextCsvCell = TxtLine
End Function
 
' This function returns the content of the string up to the first ";"
' Ex: "1;2;3" returns "1"
' Returns an empty string if no ";" are found
Function CurrCsvCell(TxtLine)
    iPos = InStr(TxtLine,";")
    If iPos = 0 Then
        CurrCsvCell = ""
    Else
        CurrCsvCell = Left(TxtLine,iPos - 1)
    End If
End Function
 
Function Process(vPerfDate) 
 
    dim objXML, objLst, objHdl, noOfFund, fs, isFound, isFundFound, fCsvPerf, isError, i, j
    dim FundNumberFront, FundNumberBack, FundNameEn, FundNameFr, FundPerfCode
    Dim c3mo, c6mo, c1yr, c3yr, c5yr, c10yr, cYTD, cIncept, cFormatted, cCurrPct
 
    Set objXML = Server.CreateObject("Microsoft.XMLDOM")
    Set objLst = Server.CreateObject("Microsoft.XMLDOM")
    Set objHdl = Server.CreateObject("Microsoft.XMLDOM")
 
    objXML.async = False
    objXML.Load (Server.MapPath("data/MyFundList.xml"))
 
    If objXML.parseError.errorCode <> 0 Then
        Response.Write(objXML.parseError.reason)
        Response.End
    End If
 
    Set objLst = objXML.getElementsByTagName("Fund") 
    noOfFund = objLst.length
 
    dim csvPerf
    dim tDate
 
    isError = true
 
    Set fs=Server.CreateObject("Scripting.FileSystemObject")
 
	csvPerf = "data/" & "perf." & year(vPerfDate) & Add0(month(vPerfDate)) & Add0(day(vPerfDate))
 
	csvPerf = server.mappath(csvPerf)
 
	If (fs.FileExists(csvPerf))= True Then
        isFound = true
		isError = false		
	End If    
 
    if isError = true then 
        Response.Write ("<b>An error has occured, no file was found <br><br>")
        Response.Write ("Performance data file found " & " = " & fs.FileExists(csvPerf) & "<br><br>")
        Response.Write ("Please upload missing files</b>")
        Response.End
    end if

Deuxème partie de code et celle que j'essais de corriger.....

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
 
    Set RegularExpressionObject = New RegExp
 
    For i = 0 To (noOfFund - 1)
        Set objHdl      = objLst.item(i)  
        FundNumberFront = objHdl.childNodes(0).text
        FundNumberBack  = objHdl.childNodes(1).text
        FundNameEn      = objHdl.childNodes(2).text
        FundNameFr      = objHdl.childNodes(3).text
        FundPerfCode    = objHdl.childNodes(4).text
 
        set fCsvPerf = fs.opentextfile(csvPerf) 
 
        dim cLine, iPos, iCell
        cLine = ""
        isFundFound = False
 
        while not fCsvPerf.AtEndOfStream
            cLine = fCsvPerf.readLine	
            iPos  = 0
            iCell = 1
 
            While iCell < 25
                cLine = NextCsvCell(iCell, cLine)
            Wend
 
            If CurrCsvCell(cLine) = FundPerfCode Then
                isFundFound = True
 
'C'EST ICI QUE JE DOIS RETOURNÉ AU DÉBUT DE MA LIGNE AVANT DE PASSER À LA SUIVANTE MAIS COMMENT ?
 
 
                While iCell < 24
                    cLine = NextCsvCell(iCell, cLine)
 
                    Select Case iCell
                    Case 10 c3mo    = CurrCsvCell(cLine)
                    Case 11 c6mo    = CurrCsvCell(cLine)
	       Case 13 c1yr    = CurrCsvCell(cLine)
	       Case 15 c3yr    = CurrCsvCell(cLine)
                    Case 17 c5yr    = CurrCsvCell(cLine)
	       Case 22 c10yr   = CurrCsvCell(cLine)
                    Case 23 cYTD    = CurrCsvCell(cLine)
                    Case 24 cIncept = CurrCsvCell(cLine)
                    End Select
                Wend
            End If
        wend
Qui fonctionnait très bien avant qu l'on modifie le formatage (remise en page xls) du fichier source.

Le fichier source demeure un csv mais les ";" ont tous changés de place dans les lignes (il y a beaucoup plus maintenant)

Je veux seulement retourner au début de ma ligne pour qu'il ramasse le data. La validation est faite seulement à la fin de la ligne et donc passe à la ligne suivante avant même d'avoir pris les données que je veux.

Merci !