Gandu <cp**********@yahoo.com> wrote:
: Could a C guru please help me? Suppose I have an ASCII text file. Now,
: I want to read in data from this file, line by line, and parse each
: line. What would be a proper way to determine what the delimiter(csv,
: tsv) is, and what is the character at the end of each line, i.e., the
: line-termination character. Any help in this regard would be greatly
: appreciated.
I'm not a C guru, but the way this is done as commonly recommended on
comp.lang.c is to use fgets() and sscanf(). fgets() reads the line
in and sscanf() parses the line. To see if the line is CSV or TSV,
you can use strchr(), and choose the appropriate format accordingly.
Check out comp.lang.c's FAQ for examples of fgets() and sscanf()
working together.
Paul
--
Paul D. Boyle
bo***@laue.chem.ncsu.edu
North Carolina State University
http://www.xray.ncsu.edu