|
▼えるてそろ さん:
こんばんは。
DATE:05/06/08 07:13:20
METHOD:PROXY
SERVER:ns.xxxxx.jp
USER:192.168.7.7
CLIENTIP:192.168.7.7
SERVERIP:111.111.222.333
DOMAIN:www.yahoo.co.jp
PATH:mail_img/tuesdaaaaaaaaaaaaaaaaaaaaaaa
----------------------------------
こんな感じの元データで宜しければ
Sub 加工してから()
Dim FSO As Object
Dim TName As String '取込テーブル名
Dim RFile As Object
Dim RPath As String '元のファイルフルパス
Dim RName As String '元のファイル名
Dim WFile As Object
Dim I As Long
Dim L As String
TName = "T_取り込み"
RPath = "C:\temp"
RName = "Log.txt"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set RFile = FSO.OpenTextFile(RPath & "\" & RName)
Set WFile = FSO.CreateTextFile(RPath & "\temp.csv")
WFile.WriteLine _
"LOGDATE,LOGTIME,METHOD,SERVER," _
& "USER,CLIENTIP,SERVERIP,DOMAIN,LOGPATH"
Do Until RFile.AtEndOfStream
For I = 1 To 9
L = RFile.ReadLine
Select Case I
Case 1
WFile.Write Mid(L, 6, 8) & "," & Mid(L, 15, 8) & ","
Case 2, 3, 7
WFile.Write Right(L, Len(L) - 7) & ","
Case 4
WFile.Write Chr(34) & Right(L, Len(L) - 5) & Chr(34) & ","
Case 5, 6
WFile.Write Chr(34) & Right(L, Len(L) - 9) & Chr(34) & ","
Case 8
WFile.WriteLine Right(L, Len(L) - 5)
End Select
Next
Loop
WFile.Close: Set WFile = Nothing
RFile.Close: Set rdile = Nothing
DoCmd.TransferText acImportDelim, , TName, RPath & "\temp.csv", True
FSO.DeleteFile RPath & "\temp.csv"
Set FSO = Nothing
End Sub
「DATE」「PATH」などは予約語なので名前を変えてあります。
外していたら申し訳ないです。
|
|