need fast parser for comma/space delimited numbers
Christian Tismer
tismer at tismer.com
Sat Mar 18 14:21:39 EST 2000
Gordon McMillan wrote:
>
> Les Schaffer wants speed:
...
> For the comma case, you might try:
> s = join(split(strLines[i], ','), ' ')
> num = map(float, split(s))
> or
> t = split(strLines[i], ',')
> t = map(strip, t)
> num = map(float, t)
As an addition:
s = replace(strLines[i], ',', ' ')
is faster than
s = join(split(strLines[i], ','), ' ')
string.translate *might* be again a little faster.
ciao - chris
--
Christian Tismer :^) <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net
14163 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
we're tired of banana software - shipped green, ripens at home
More information about the Python-list
mailing list