title: Converting data from .csv file to .json - Python
body: <p>I need to convert data from my <code>csv</code> file to the one i am gonna use which is <code>.js</code>. </p>
  
  <pre><code>Lp.;Name;Surname;Desc;Unit;Comment
  1;Jan;Makowski;Inf;km;
  2;Anna;Nowak;Pts;km;Brak reakcji
  </code></pre>
  
  <p>If you can see column <code>'comment'</code> does not always have record and I need to keep it that way. Also between data there is amount of tabs I need to set as well.</p>
  
  <p><a href="https://i.stack.imgur.com/PwKU1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PwKU1.png" alt="enter image description here"></a></p>
  
  <p>I've a file,i am working on right now but It show's me data in row like :</p>
  
  <pre><code>[{"Lp.;Name;Surname;Desc;Unit;Comment": "1;Jan;Makowski;Inf;km;"}, {"Lp.;Name;Surname;Desc;Unit;Comment": "2;Anna;Nowak;Pts;km;Brak reakcji"...]
  </code></pre>
  
  <p>I am new to python and I have no idea how to define what I need to get.</p>
  
  <p>@@ Edit I managed to do that...</p>
  
  <pre><code>import json
  import csv
  
  # Deklaracja danych
  fieldnames = ("Lp.", "Name", "Surname", "Desc", "Unit", "Comment")
  
  #  Otwieranie plików
  with open('file.csv', 'r', encoding = "utf8") as csvfile:
      reader = csv.DictReader(csvfile) # ,fieldnames)
      rows = list(reader)
  
  # Zamykamy plik
  csvfile.close()
  
  # Tworzymy plik z danych
  with open('file.json', 'w', encoding = "utf8") as jsonfile:
      json.dump(rows,jsonfile)
      # jsonfile.write(s.replace(';', '/t'))
  # Zamykamy plik
  csvfile.close()
  </code></pre>