Mark Harrison wrote:
> What is the best way to process a text file of delimited strings?
> I've got a file where strings are quoted with at-signs, @like [EMAIL 
> PROTECTED]
> At-signs in the string are represented as doubled @@.
> 
> What's the most efficient way to process this?  Failing all
> else I will split the string into characters and use a FSM,
> but it seems that's not very pythonesqe.
> 
> @rv@ 2 @db.locks@ @//depot/hello.txt@ @mh@ @mh@ 1 1 44
> @pv@ 0 @db.changex@ 44 44 @mh@ @mh@ 1118875308 0 @ :@@: :@@@@: @
> 

 >>> import csv
 >>> list(csv.reader(file('at_quotes.txt', 'rb'), delimiter=' ', 
quotechar='@'))
[['rv', '2', 'db.locks', '//depot/hello.txt', 'mh', 'mh', '1', '1', 
'44'], ['pv'
, '0', 'db.changex', '44', '44', 'mh', 'mh', '1118875308', '0', ' :@: 
:@@: ']]
 >>>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to