vb.net - copying from a tab delimited text file to itself -
I have a tab delimited text file:
name \ t loan duration \ t The loan amount John \ t 5 years \ t 6000 all \ t 5 years \ t 6000 Jane \ t 1 month \ t 100 I am looking to copy those lines where " New lines will be attached at the end of the file as a result for showing the comparison of "loan duration" = "5 years", where "loan duration" = "one month".
The last result to get the final result is:
name \ t loan duration \ t loan amount John \ t 5 years \ t 6000 all \ t 5 years \ t 6000 Jane \ t 1 month \ t 100 John \ t 1 month \ t 100 all \ t 1 month \ t 100 I have about it Visual Basic.Net, and so far, this What have I come up with
isI am drawing as an empty to how to proceed, and thought that I would ask for help.
is a little ugly but the beginning
// c #
OpenFile dialog dialog = new OpenFileDialog (); Dialog.ShowDialog (); String filePath = dialog.FileName; // In this list, we store a 5-year match. & Lt; String []> Five Years = New List & lt; String []> (); // open a reader streamrider tr = new streamrider (file path); // 1 degree line reaing string line = tr.ReadLine (); While (Line! = Null & Line! = "" & Amp; Line! = "\ N") {// Divide the line by tab, String [] lineByTabs = line.Split ('\ t'); // If the second term is equivalent to '5 years' (LineBitib [1] .Equals ("5 years")) {// change from 5 years to 1 month, and one hundred of 100 Linebytab [1] = "1 month"; Linebiteab [2] = "100"; FiveYears.Add (lineByTabs); } Line = tr.ReadLine (); } // Close reader tr.Close (); // Open the file and open the lines TextWriter tw = new streamer (file path, true); Fifth (string [] rows in five years) {tw.WriteLine (line [0] + "\ t" + line [1] + "\ t" + line [2]); } Tw.close (); }> Vb.net Smooth dialogue OpenFileDialog = New OpenFileDialog dim filePath, line string is listed as string fiveYears (string of) As in the = new list (string of ()) Dim lineByTabs string () Dim TR StreamReader dim tw TextWriter dialog.ShowDialog () filePath = dialog.FileName TR = New StreamReader (filepath) line = tr.ReadLine () While this is not the case as in line = linebiteb = line. Split (vbTab) if linebytab (1). Acquires ("5 years") then LineBitab (1) = "1 month" LineByTab (2) = "100" Five Years Add (linebytabs) end if line = Tr.ReadLine () end while tr.Close () tw = New StreamWriter (filePath, True) string in the form of each row tw.writeLine (lines (0) + vbTab + Lines (1) + vbTab + line (2)) next two times. ()
Hope this helps
Note: Flies must be eliminated in a new line and given format To (3 colums) folows
Comments
Post a Comment