Q
Quentin
I am currently working with a text file and cannot seem to get it to
filter right. I am trying to delete every line above a keyword
"Recipe" and every line below a keyword. Or just move every line
between those key words to a new file. Either way I having
difficulties. Below is a sample of the text file and code.
Sample file (only original is much larger)
2,3,56,554,22,11,1,2,9,
234,42,12,4,4,4,,2,3,2,3
"Recipe"
2,3,32545,655,5656,56,
4,56,4565,56,565,654,45,
2,45,46,456,473,6,67565
"End of Recipe"
2,7,5,7,452,7,6,8,5,4,7,4
54,6,6,4,6,578,5,6,56,7,5,
I would only like to keep what is inbetween Recipe and End of Recipe.
Dim streamR As StreamReader = IO.File.OpenText_("c:\MultiTemp1.txt")
Dim streamw As StreamWriter = IO.File.CreateText_("c:
\filtered2.txt")
Dim strInput As String
While Not streamR.EndOfStream
strInput = streamR.ReadLine
If strInput.Contains("End") Then
Else
If InStr(strInput, "Recipe", CompareMethod.Text) > 0
Then
strInput = streamR.ReadLine
streamw.WriteLine(strInput)
End If
End If
End While
streamw.Close()
streamR.Close()
Any help would by great.thanks!
filter right. I am trying to delete every line above a keyword
"Recipe" and every line below a keyword. Or just move every line
between those key words to a new file. Either way I having
difficulties. Below is a sample of the text file and code.
Sample file (only original is much larger)
2,3,56,554,22,11,1,2,9,
234,42,12,4,4,4,,2,3,2,3
"Recipe"
2,3,32545,655,5656,56,
4,56,4565,56,565,654,45,
2,45,46,456,473,6,67565
"End of Recipe"
2,7,5,7,452,7,6,8,5,4,7,4
54,6,6,4,6,578,5,6,56,7,5,
I would only like to keep what is inbetween Recipe and End of Recipe.
Dim streamR As StreamReader = IO.File.OpenText_("c:\MultiTemp1.txt")
Dim streamw As StreamWriter = IO.File.CreateText_("c:
\filtered2.txt")
Dim strInput As String
While Not streamR.EndOfStream
strInput = streamR.ReadLine
If strInput.Contains("End") Then
Else
If InStr(strInput, "Recipe", CompareMethod.Text) > 0
Then
strInput = streamR.ReadLine
streamw.WriteLine(strInput)
End If
End If
End While
streamw.Close()
streamR.Close()
Any help would by great.thanks!