|
Parse a single line (or fragment).
Uses the options set in the parser object.
Can parse lists - including nested lists. (If recursive is
False then nested lists will cause a BadLineError).
Return value depends on options.
If comment is False it returns outvalue
If comment is True it returns (outvalue, comment). (Even if
comment is just '').
If force_list is False then outvalue may be a list or a
single item.
If force_list is True then outvalue will always be a list -
even if it has just one member.
List syntax :
Comma separated lines a, b, c, d
- Lists can optionally be between square or ordinary brackets
- [a, b, c, d]
- (a, b, c, d)
Nested lists must be between brackets - a, [a, b, c, d], c
A single element list can be shown by a trailing quote - a,
An empty list is shown by () or []
Elements can be quoted with single or double quotes (but can't contain
both).
The line can optionally end with a comment (preeded by a '#').
This depends on the comment attribute.
If the line is badly built then this method will raise one of :
CommentError, BadLineError, UnQuoteError
Using the csv option is the same as setting :
'recursive': False
'force_list': True
'comment': False
-
|