shooff27

shooff27

  • NA
  • 3
  • 0

Read and parse comma-delimited file

Dec 16 2003 3:51 PM
Read and parse comma-delimited file i need away to read from the end of the file to the begining instead of begining to end as this code does can anyone help me using System; using System.IO; public class rev { public static void Main(string[] a) { string line; string[] strings = new string[100]; char[] separate = {','}; int i, lineNum; if (a.Length != 1) { Console.WriteLine("Usage: prog.exe filename.filetype"); return; } StreamReader file = new StreamReader(a[0]); lineNum = 0; Console.WriteLine(); while ((line = file.ReadLine()) != null) { ++lineNum; i = 0; foreach (string arg in line.Split(separate)) { i++; strings[i] = arg.Trim(); Console.WriteLine("Line {0}, token{1}: {2}", lineNum, i, strings[i]); } Console.WriteLine(); } file.Close(); } }

Answers (3)