Jatin Mistry

Jatin Mistry

  • NA
  • 1
  • 2.1k

Reading data from a txt file and seperating according to delimits

Oct 23 2006 7:00 PM
hey, i am stuck with this application that i need to build. was wondering if someone can help me. i have to build an application that reads data from a txt file, seperate the data and then insert them into a db. data in this context is string and int's all seperated by comma's ie. one single entry is in a format like int,int,sting,string,string,string,string,string,string,string,int,int,int,int the delimit that i have is the ',' character. the problem that i am facing is that some of the string part of the data itself contain ','. an extract of my code is below /*read in the text file into string s...*/ char[] delimit = new char[] { '\n' };//delimit to seperate the individual entries char[] delimit2 = new char[] { ',' };//delimit to seperate the columns foreach (string substr in s.Split(delimit)) { if (substr.Length>0 )//to avoid empty '\n' at EOF { int columns = 14; string[] person =new string[columns]; int i=0; foreach (string sub in substr.split(delimit2)) { person[i]=sub; i++; } } /*process ahead and insert into db.*/ can some1 help?

Answers (1)