Note that there are some explanatory texts on larger screens.

plurals
  1. PORead from a text file and write it to another text file into a comma delimited format using StreamWriter
    primarykey
    data
    text
    <p>I am trying to write data that has been read from a text file and write it to another text file into a comma delimited format. I need to know what the code is to come to that conclusion. This where I need the help.</p> <p>Example:</p> <p>Original Data looks like this:</p> <blockquote> <p>Agnico-Eagle Mines<br> COM<br> 008474108<br> 28996843<br> 716800<br> 716800<br> N/A<br> N/A<br> <br> N/A<br> 716800<br> N/A<br> Agrium Inc.<br> COM<br> 008916108<br> 145739616<br> 1646617<br> 1646617<br> N/A<br> N/A<br> <br> N/A<br> 1646617<br> N/A<br> AuRico Gold Inc<br> COM<br> 05155C105<br> 504505<br> 62875<br> 62875<br> N/A<br> N/A<br> <br> N/A<br> 62875<br> N/A<br></p> </blockquote> <p>This is how I want the data to look like in the RichTextBox:</p> <blockquote> <p>Agnico-Eagle Mines,COM,008474108,28996843,716800,716800,N/A,N/A,,N/A,716800,N/A<br> Agrium Inc.,COM,008916108,145739616,1646617,1646617,N/A,N/A,,N/A,1646617,N/A<br> AuRico Gold Inc,COM,05155C105,504505,62875,62875,N/A,N/A,,N/A,62875,N/A<br></p> </blockquote> <p>Just so you know from the original text data, I want to read the first line, then add a comma and then read the 2nd line append it to the first line then add a comma, and this goes one for the 1st 12 lines. The end of the 12th line has no comma. Then the process starts over again. </p> <p>Any info is appreciated. </p> <p>Thanks.</p> <p>Below is the code that I have written thus far. </p> <pre><code> private void button1_Click(object sender, EventArgs e) { using (StreamReader Reader = new StreamReader(@"C:\Original_Text_File.txt")) { while (!Reader.EndOfStream) { TextBox1.AppendText(Reader.ReadLine()); } } } private void button2_Click(object sender, EventArgs e) { using (StreamWriter Writer = new StreamWriter(@"C:\Original_Text_File.txt")) { Writer.WriteLine(TextBox1.Text); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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