-
July 18th, 2007, 08:24 PM
#1
Member
Data Manipulation in VB.NET
I have just started with .NET programming and I had a question as to how I should go about doing this data manipulation.
Its a little hard to explain exactly what I want but bare with me.
What I have are documents that are formatted like so
Code:
Option
$Comment
Value 5.5 6.6 77
Value 3.0 .04 .90
DP -2 3 4
Value 02 9 84
XPAR 34 55 33
...
Option
$Comment
...
This continues based on simulation that has been run. The data sets all start with Option.
What I want to do is scan through the document line by line (because I'm terrible with regular expressions) and search for "XPAR". If I find "XPAR" I need to delete that entire Option. That is I need to decriment and delete each line back up to Option and then skip foward to the next "Option" and continue to write to a new file.
So the new file will not have the data set "Option" where "XPAR" is found.
My idea was to read line by line into a temporary file until i found Xpar, then search back up and delete lines until i get to Option, skip to the next Option and continue to read line by line. This is the function that I have so far.
Code:
Friend Sub import(ByVal strInputFile As String)
Dim tmpFile As String = Path.GetTempFileName()
Dim fsTemp As New FileStream(tmpFile, FileMode.Create)
Dim sr As StreamReader = New StreamReader(strInputFile)
Dim sw As StreamWriter = New StreamWriter(tmpFile)
While sr.Peek() > -1
sw.WriteLine(sr.ReadLine)
If sr.ReadLine.Contains("CCONE") Then
End If
End While
sr.Close()
sw.Close()
fsTemp.Close()
File.Delete(tmpFile)
End Sub
I don't know a whole lot about FileStreams, StreamReader/Writers so I don't really know how to go about scanning up and deleting while writing to the file.
Any suggestions or tips?
Similar Threads
-
By cheyenne1212 in forum Miscellaneous Security Discussions
Replies: 7
Last Post: February 1st, 2012, 02:51 PM
-
By ThePreacher in forum Miscellaneous Security Discussions
Replies: 17
Last Post: December 14th, 2006, 09:37 PM
-
By -DaRK-RaiDeR- in forum Newbie Security Questions
Replies: 9
Last Post: December 14th, 2002, 08:38 PM
-
By E5C4P3 in forum Miscellaneous Security Discussions
Replies: 5
Last Post: March 7th, 2002, 07:35 AM
-
By antihaxor in forum Non-Security Archives
Replies: 0
Last Post: January 24th, 2002, 05:42 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|