Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A litle ugly but is a start.</p> <p>//c#</p> <pre><code> OpenFileDialog dialog = new OpenFileDialog(); dialog.ShowDialog(); string filePath = dialog.FileName; //in this list we store the match of 5 years. List&lt;string[]&gt; fiveYears = new List&lt;string[]&gt;(); //open a reader. StreamReader tr = new StreamReader(filePath); //reaing 1° line. string line=tr.ReadLine(); while (line != null &amp;&amp; line != "" &amp;&amp; line != "\n") { //split de line by tabs. string[] lineByTabs = line.Split('\t'); //if the second term equals '5 years' if (lineByTabs[1].Equals("5 years")) { //change from 5 years to 1 month, and to a lonan of 100. lineByTabs[1] = "1 month"; lineByTabs[2] = "100"; fiveYears.Add(lineByTabs); } line = tr.ReadLine(); } //close reader tr.Close(); //open the file and apend lines. TextWriter tw = new StreamWriter(filePath, true); foreach (string[] lines in fiveYears) { tw.WriteLine(lines[0] + "\t" + lines[1] + "\t" + lines[2]); } tw.Close(); } </code></pre> <p>'vb.net</p> <pre><code> Dim dialog As OpenFileDialog = New OpenFileDialog Dim filePath, line As String Dim fiveYears As List(Of String()) = New List(Of String()) Dim lineByTabs As String() Dim tr As StreamReader Dim tw As TextWriter dialog.ShowDialog() filePath = dialog.FileName tr = New StreamReader(filePath) line = tr.ReadLine() While Not line = "" lineByTabs = line.Split(vbTab) If lineByTabs(1).Equals("5 years") Then lineByTabs(1) = "1 month" lineByTabs(2) = "100" fiveYears.Add(lineByTabs) End If line = tr.ReadLine() End While tr.Close() tw = New StreamWriter(filePath, True) For Each lines As String() In fiveYears tw.WriteLine(lines(0) + vbTab + lines(1) + vbTab + lines(2)) Next tw.Close() </code></pre> <p>hope it helps</p> <p><strong>note:</strong> flie has to end in a new line. and folows the given format (3 colums).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload