Leif K-Brooks wrote:
> 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 @@.
>
>
import re
_at_re = re.compile
On Thu, 16 Jun 2005 09:36:56 +1000, John Machin wrote:
>> like this ?
>
> No, not like that. The OP said that an embedded @ was doubled.
you are right, sorry :)
anyway, if @@ -> @
an empty field map to what ?
--
http://mail.python.org/mailman/listinfo/python-list
Mark -
Let me weigh in with a pyparsing entry to your puzzle. It wont be
blazingly fast, but at least it will give you another data point in
your comparison of approaches. Note that the parser can do the
string-to-int conversion for you during the parsing pass.
If @rv@ and @pv@ are record type
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 @@.
>>> import re
>>> _at_re = re.compile('(?>> def split_at_line(line):
Paul McNett <[EMAIL PROTECTED]> wrote:
> 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 @@.
>
> Have you taken
Nicola Mingotti wrote:
> On Wed, 15 Jun 2005 23:03:55 +, Mark Harrison wrote:
>
>
>>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.
>
>
> like this ?
No, not like that. The
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
> el
On Wed, 15 Jun 2005 23:03:55 +, Mark Harrison wrote:
> 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.
like this ?
>>> s = "@[EMAIL PROTECTED]@@[EMAIL PROTECTED]"
>>> s.split
You could use regular expressions... it's an FSM of some kind but it's
faster *g*
check this snippet out:
def mysplit(s):
pattern = '((?:"[^"]*")|(?:[^ ]+))'
tmp = re.split(pattern, s)
res = [ifelse(i[0] in ('"',"'"), lambda:i[1:-1], lambda:i) for i in
tmp if i.strip()]
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 @@.
Have you taken a look at the csv module yet? No guarantees, but it m
10 matches
Mail list logo