CSV file edition

Alain Ketterlin alain at universite-de-strasbourg.fr.invalid
Tue Jan 9 15:41:54 EST 2018


Manuel Rincon <tradingroompitalito at gmail.com> writes:

[...]
> Type=0  MarketTime=11:18:26.549  Price=112.8300
> Type=0  MarketTime=11:18:28.792  Price=112.8300
[...]
>
> I would need to filter only the numeric part of all the columns.

I assume that by "numeric" you mean the value after Price=

line.split()[2].split('=')[1]
line.rsplit('=',1)[1]
line.rpartition('=')[2]
line[line.rfind('=')+1:]

I prefer the last one. You can also use regexps, but it would be
overkill if your lines are that simple.

If your lines are really that simple, use line[39:] (check that 39 is
correct). Your data look like fixed-width fields.

-- Alain.



More information about the Python-list mailing list