Nicer way of strip and replace?

Markus Rosenstihl mrosenstihl at macnews.de
Tue Oct 11 19:04:09 EDT 2005


On 2005-10-11 23:45:46 +0200, Paul Rubin <http://phr.cx@NOSPAM.invalid> said:

> Markus Rosenstihl <mrosenstihl at macnews.de> writes:
>> This looks ugly (I htink)  and I wonder if there is a nicer way to
>> strip commata and change the comma to a dot already when reading in.
>> Or should i do it with a shell script before processing in python?
> 
> First of all you should just set your locale to use comma instead
> of dot as the numeric decimal, instead of translating commas to dots.

Yes that is true, but most of the time I use a dot as numerical decimal.


> 
> Second, for the field separation, see if you can configure the csv
> module to do it for you.

indeed, it did it correctly by default:

read_file = csv.reader(open('2005_08_Rechnung_4963184011.dat', 'r'), 
delimiter="\t")
for row in read_file:
	rechnung.append(row)







More information about the Python-list mailing list