Quantcast
Channel: Finite state machine for CSV data - Code Review Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by janos for Finite state machine for CSV data

$
0
0

So my question is this: is this block at the end some sort of anti-pattern, and is it something that's going to come back to bite me in the future?

Not necessarily.It depends on whether line can contain end-of-line markers.

If line can contain an EOL character that marks the end of the CSV record for you,then you could move the logic from the last switch into case EOL: for the state-specific handling as appropriate,and stop further processing.Or you want to support multi-line CSV records (newline characters embedded within quotes), then you could continue processing the next line.

If the full length of line is expected to be the complete CSV record,then it's fine to not terminate it with an explicit EOL and handle it in the extra switch as you did.


Viewing all articles
Browse latest Browse all 2

Trending Articles