Skip to content

Tab Separeator!

M Farag

Asked Dec 8, 2006, 2:43 AM EST4 answers
Share
LinkedInX
Hii All ,


i have a text file contains numbers with the following format , how can i read this numbers to apply math operations on

6666 tab 6666 tab 6666
6666 tab 6666 tab 6666
6666 tab 6666 tab 6666
6666 tab 6666 tab 6666

how to neglect this tab ? and put each 4 digits into avariable ?

then i'll send this varables each one into a cell in Excel

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    You can use the following to split each line of your file into an array

    string line;
    string[] list;

    TextReader tr = new StreamReader(YourFile);

    while ((line = tr.ReadLine()) != null)
    {
    list = line.Split(new char[] {'\t'});
    foreach (string  line in list)
    {
    //do stuff with array
    }
    }

    Why would you need your program to output this file to excel when it's already in a format that excel can read?

    0
  • 0
    o.k , could you tell please how Excel can read txt files ?
    0
  • 0
    bythe way am going to arrange the columns and the rown ,i'll not paste them directly
    0
  • 0
    You open Excel, click the Data menu, click get external data then import text file.

    That's how.
    0