Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: file parsing

Reply
Thread Tools

Re: file parsing

 
 
Pete
Guest
Posts: n/a
 
      08-06-2003
Please excuse my ignorance.....but what does it mean to parse a file?

"Vladimir Ralev" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> Hello!
>
> I need to parse a file that contains few datasets separated by an
> empty line, like that:
> /*----start of file to be parsed-----*/
> 3 4 5
> 2 3 6
> 4 6 8
> 5 7 9
>
> 7 4 2
> 7 4 3
> 5 5 5
> 8 3 1
> 3 4 1
>
> 4 66 6
> 3 466 4
> 1 11 77864
> /*------------ END OF FILE ---------*/
>
> Those are ints separated by intervals, three per line.
> You see here three datasets - the first is the first four lines, the
> empty line then and then the 5 lines for the second set...and so on.
>
> How do I detect an empty line so I could decide where the next set
> begins using C++ file IO functions?
>
> I tryied to:
> ifstream infile("file");
> infile>>intvar, but when I check for "\n" i am already skewed coz I
> wasted walked the iterator forward too much.
>
> Thank you!



 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-06-2003
"Pete" <(E-Mail Removed)> wrote...
> Please excuse my ignorance.....but what does it mean to parse a file?


Generally, as my understanding of it goes, parsing is separating
some collection (or stream) into individual items (often called
"tokens") and then interpreting each token depending on conditions
set forth in the algorithm. For example, parsing a C++ source file
would include figuring out the sequence of tokens (done at the
preprocessing step) and then making sense out of those tokens. It
is done by the compiler, it is done by many text editors nowadays
(those who colour the tokens differently when displaying the code,
so called "syntax highlighting"), it is done by separate syntax
and logical error checkers (PCLint or something like that)...

In the OP's case parsing is reading the individual numbers and the
empty lines, storing the numbers somewhere and interpreting the
empty lines as special separators.

Victor


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 09:01 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 08:58 PM
In file parsing, taking the first few characters of a text file after a readfile or streamreader file read... .Net Sports ASP .Net 11 01-17-2006 12:44 AM
SAX Parsing - Weird results when parsing content between tags. Naren XML 0 05-11-2004 07:25 PM
Perl expression for parsing CSV (ignoring parsing commas when in double quotes) GIMME Perl 2 02-11-2004 05:40 PM



Advertisments