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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| Const FOR_READING = 1
Const OVERWRITE = True
Const FORCE = True
Const ACCENT = "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÌÍÎÏìíîïÙÚÛÜùúûüÿÑñÇç"
Const NOACCENT = "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuyNnCc"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Fonction SansAccents() : Retourne une chaîne sans accents
'
Function SansAccents(strAvecAccents)
' Définition des variables locales
Dim i
Dim lettre
Dim strSansAccents
strSansAccents = strAvecAccents
For i = 1 To Len(ACCENT)
lettre = Mid(ACCENT, i, 1)
If InStr(strSansAccents, lettre) > 0 Then
strSansAccents = Replace(strSansAccents, lettre, Mid(NOACCENT, i, 1))
End If
Next
SansAccents = strSansAccents
' Libération des variables locales
Set i = Nothing
Set lettre = Nothing
Set strSansAccents = Nothing
End Function
''''''''''''''''''''''''''''''
strAccountFile = "C:\eho\Accounts.csv"
strTempFile = strAccountFile & ".temp"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strAccountFile) Then
WScript.Echo "Le fichier " & strAccountFile & " n'existe pas" & VbCrLf & "FIN DU PROGRAMME"
WScript.Quit 1
End If
Set objNotOkToBeFormatFile = objFSO.OpenTextFile(strAccountFile, FOR_READING)
Set objOkToBeFormatFile = objFSO.CreateTextFile(strTempFile, OVERWRITE)
nbGuillemets = 0
Do Until objNotOkToBeFormatFile.AtEndOfStream
strCharacter = objNotOkToBeFormatFile.Read(1)
If strCharacter = chr(34) Then
nbGuillemets = nbGuillemets + 1
objOkToBeFormatFile.Write strCharacter
Else
If nbGuillemets Mod 2 = 1 Then
objOkToBeFormatFile.Write Replace(strCharacter, Chr(10), Chr(32))
Else
objOkToBeFormatFile.Write Replace(strCharacter, Chr(44), Chr(59))
End If
End If
Loop
objOkToBeFormatFile.Close
objNotOkToBeFormatFile.Close
objFSO.DeleteFile strAccountFile, FORCE
Set objNotFormatedFile = objFSO.OpenTextFile(strTempFile, FOR_READING)
Set objFormatedFile = objFSO.CreateTextFile(strAccountFile, OVERWRITE)
strOldLine = objNotFormatedFile.ReadLine
arrLine = Split(strOldLine, ";")
nbCols = Ubound(arrLine)
If nbCols < 18 Then
WScript.Quit 10
End If
strNewLine = ""
For j = Lbound(arrLine) To Ubound(arrLine)
strNewLine = strNewLine + arrLine(j) + ","
Next
strNewLine = Left(strNewLine, len(strNewLine)-1)
objFormatedFile.WriteLine strNewLine
Do Until objNotFormatedFile.AtEndOfStream
strOldLine = objNotFormatedFile.ReadLine
If strOldLine <> "" Then
arrLine = split(strOldLine, ";")
strTemp = arrLine(0)
arrLine(0) = UCase(SansAccents(strTemp))
strTemp = arrLine(16)
arrLine(16) = UCase(SansAccents(strTemp))
strTemp = arrLine(18)
arrLine(18) = UCase(SansAccents(strTemp))
strNewLine = ""
For j = Lbound(arrLine) To Ubound(arrLine)
strNewLine = strNewLine + arrLine(j) + ","
Next
strNewLine = Left(strNewLine, len(strNewLine)-1)
objFormatedFile.WriteLine strNewLine
End If
Loop
objNotFormatedFile.Close
objFormatedFile.Close
objFSO.DeleteFile strTempFile, FORCE
Set objOkToBeFormatFile = Nothing
Set objNotOkToBeFormatFile = Nothing
Set objNotFormatedFile = Nothing
Set objFormatedFile = Nothing
Set objFSO = Nothing
WScript.Echo "FIN DU PROGRAMME" |
Partager