title: Python - Change a comma to a decimal in a list
body: <p>I'm usting Python 3.7. I'm trying to convert a European decimal point, i.e. a comma into a decimal point (i.e. a dot).</p>
  
  <p>The original file is a .csv file. </p>
  
  <p>The code I have is: </p>
  
  <pre><code>#!/usr/bin/env python
  import sys
  
  for line in sys.stdin:
      # remove leading and trailing whitespace
      line = line.strip()
      # split data values into list
      data = line.split("\t")
  
      data = "{,:.}".format(data)
      print(data)
  </code></pre>
  
  <p>The <code>data = "{,:.}".format(data)</code>  is causing issue.</p>
  
  <p>The output I get is: </p>
  
  <pre><code>Traceback (most recent call last):
    File "conPrep.py", line 10, in &lt;module&gt;
      data = "{,:.}".format(data)
  KeyError: ','
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p><a href="https://i.stack.imgur.com/G0hG0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G0hG0.png" alt="Sample of data"></a></p>
  
  <hr/>
  
  <pre><code>#!/usr/bin/env python
  import csv
  from io import StringIO
  import locale
  import sys
  from locale import atof
  
  data = sys.stdin.readlines()
  
  reader = csv.reader(data, delimiter='\t')
  loc = locale.getlocale()
  locale.setlocale(locale.LC_ALL, 'german')
  for row in reader:
      print([atof(x) for x in row])
  locale.setlocale(locale.LC_ALL, loc) 
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Traceback (most recent call last):
    File "conPrep.py", line 14, in &lt;module&gt;
      print([atof(x) for x in row])
    File "conPrep.py", line 14, in &lt;listcomp&gt;
      print([atof(x) for x in row])
    File "C:\Python37\lib\locale.py", line 326, in atof
      return func(delocalize(string))
  ValueError: could not convert string to float: 'Data.Temperatura Media (C).Temperatura Minima (C).Temperatura Maxima (C).Precipitacao (mm).Final de Semana.Consumo de cerveja (litros)'
  </code></pre>