Hi:
I really need help, because I have been battling this for 3 days.
I have two files. one is called unix_dump_a.txt, the others called red_items.txt.
I want to parse the contents of the red_item file, and then parse the unix_dump.txt file, and remove data that is in the red_item file, from the unix_dump file.
I did this by writing the elements in the unix file, which were not in the red_items file, to a new file, which I called unix_strip.
Thing is that its not working as its meant to. When I check the unix_strip file (The output), I still see stuff in there, thats also in the red_item file, and thats not supposed to be.
This is what I have done so far:
Unfortunately, my code doesn't work the way I want it to, and its frustrating.. Any item thats in the red_item file should be removed from the unix_dump file, and placed in the unix_strip file.
Any ideas?
Thanks!
I really need help, because I have been battling this for 3 days.
I have two files. one is called unix_dump_a.txt, the others called red_items.txt.
I want to parse the contents of the red_item file, and then parse the unix_dump.txt file, and remove data that is in the red_item file, from the unix_dump file.
I did this by writing the elements in the unix file, which were not in the red_items file, to a new file, which I called unix_strip.
Thing is that its not working as its meant to. When I check the unix_strip file (The output), I still see stuff in there, thats also in the red_item file, and thats not supposed to be.
This is what I have done so far:
VB.NET:
[INDENT]Sub stripUnixItems()
'first create the strip file for unix
Dim fs As New FileStream(configFileDir & "\unix_strip.txt", FileMode.Create, FileAccess.Write)
'get a handle to existing unix dump file for reading
'Dim dumpFileReader = New StreamReader(configFileDir & "\unix_dump_a.txt")
'read contents of unix red list
Dim redListReader = New StreamReader(configFileDir & "\unix_red_items.txt")
'get handle to write to strip file
Dim sw = New StreamWriter(fs)
'read contents of red list line by line.
Dim redListLine As String
Do 'begin to read the redlist file
redListLine = redListReader.ReadLine()
MsgBox(redListLine)
'for each line in the redlist
'first check for wildcards
'If redListLine.Contains("*") Then
' 'handle wildcards
'Else
'the redlist items are whole text
'for each redlist line check if it exists in unix dump file
Dim currentRow() As String
Using myreader As New Microsoft.VisualBasic.FileIO.TextFieldParser(configFileDir & "\unix_dump_a.txt")
myreader.TextFieldType = FileIO.FieldType.Delimited
myreader.SetDelimiters(";")
While Not myreader.EndOfData And String.Empty.Equals(redListLine)
currentRow = myreader.ReadFields()
'we know the first 3 elements combined always give the full tag name
If Not redListLine.Contains(currentRow(0) & "." & currentRow(1) & "." & currentRow(2)) Then
'write to the strip file
Dim i As Integer
For i = 0 To currentRow.Length - 1
sw.Write(currentRow(i))
Next
sw.WriteLine()
End If
End While
End Using
'End If
Loop Until redListLine Is Nothing
End Sub[/INDENT]
Unfortunately, my code doesn't work the way I want it to, and its frustrating.. Any item thats in the red_item file should be removed from the unix_dump file, and placed in the unix_strip file.
Any ideas?
Thanks!