Ok, here is the issue I've encountered... I've been using some DAT files to track some user usage information. Due to an incorrect input, some improperly formatted data has been inserted into my files.
I need to loop through all the DAT files search them line by line and make corrections to the incorrect input.
Here is a sample of the data
'--------------------------------------------------------------
"05006","15:10:09","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:28:57","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:29:08","04/08/2011","R983-Pred"
"05006","15:29:12","04/08/2011","R983-Pred"
"05006","15:31:05","04/08/2011","R983-Pred"
"05006","15:31:06","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006",#1899-12-30 15:35:05#,#2011-04-08#,"Ortho PRE-D"
"05006","15:37:57","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:40:30","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:40:47","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:43:22","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:44:45","04/08/2011","R983-Pred"
'--------------------------------------------------------------
If you notice, line number 7 has an incorrect date and time format (fields 2 & 3)
I use a vbs file to compile the DAT files into a single file for some analysis I do, and I'm assuming I could use the structure to loop through each line and scrub this data, but I'm stumped as to how I would proceed from there, Should I be using a regex function just to search each file for all instances in that pattern and replace? Does anyone have any example of how to do this? The VBS loop I was trying to modify is below... Thanks in advance for reviewing this!
I need to loop through all the DAT files search them line by line and make corrections to the incorrect input.
Here is a sample of the data
'--------------------------------------------------------------
"05006","15:10:09","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:28:57","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:29:08","04/08/2011","R983-Pred"
"05006","15:29:12","04/08/2011","R983-Pred"
"05006","15:31:05","04/08/2011","R983-Pred"
"05006","15:31:06","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006",#1899-12-30 15:35:05#,#2011-04-08#,"Ortho PRE-D"
"05006","15:37:57","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:40:30","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:40:47","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:43:22","04/08/2011","Pre-D_CYM Remark(Year only)"
"05006","15:44:45","04/08/2011","R983-Pred"
'--------------------------------------------------------------
If you notice, line number 7 has an incorrect date and time format (fields 2 & 3)
I use a vbs file to compile the DAT files into a single file for some analysis I do, and I'm assuming I could use the structure to loop through each line and scrub this data, but I'm stumped as to how I would proceed from there, Should I be using a regex function just to search each file for all instances in that pattern and replace? Does anyone have any example of how to do this? The VBS loop I was trying to modify is below... Thanks in advance for reviewing this!
Code:
Public Sub AppendFiles()
Dim SourceNum As Integer
Dim DestNum As Integer
Dim Temp As String
Dim sOriginFolder As String
Dim sDestinationFile As String
Dim sFile, sFile2, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
On Error GoTo ErrHandler
sOriginFolder = "S:\Dental Claims Lmtd Access\DataTrack\DAT FILES"
sDestinationFile = "S:\Dental Claims Lmtd Access\DataTrack\WordTemp\MacroData.dat"
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
DestNum = FreeFile()
Open sDestinationFile For Append As DestNum
SourceNum = FreeFile()
Open sFile For Input As SourceNum
Do While Not EOF(SourceNum)
Line Input #SourceNum, Temp
Print #DestNum, Temp
Loop
CloseFiles:
' Close the destination file and the source file.
Close #DestNum
Close #SourceNum
Next
Exit Sub
ErrHandler:
'MsgBox "Error # " & Err & ": " & Error(Err)
Resume CloseFiles
End Sub