Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

239
Visualizações
I want to convert CSV to JSON file using python
import csv
import json


# defining the function to convert CSV file to JSON file
def convjson(cleanedhm, js):
    # creating a dictionary
    mydata = {}

    # reading the data from CSV file
    with open(cleanedhm, encoding='utf-8') as csvfile:
        csvRead = csv.DictReader(csvfile)

        # Converting rows into dictionary and adding it to data
        for rows in csvRead:
            mykey = rows['hmid']
            mydata[mykey] = rows

            # dumping the data
    with open('cleanedhm', encoding='utf-8') as jsonfile:
        jsonfile.write(json.dumps(mydata, indent=4))

    # filenames


cleanedhm = r'mydatalist.csv'
js = r'mydatalist.json'

# Calling the convjson function
convjson(cleanedhm, js)
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Pandas is a really great tool, and in this case it does what you need in two very easy lines!

import pandas as pd

csv = pd.read_csv (r'Path where the CSV file is saved\File Name.csv')
csv.to_json (r'Path where the new JSON file will be stored\New File Name.json')
about 4 years ago · Juan Pablo Isaza Relatório

0

process your file with pandas as a DataFrame and then export with the to_json() method

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda