Ejemplo 1: cadena csv de python a json
import json
import csv
//string_data is your string in csv format
json.dumps(list(csv.DictReader(string_data.splitlines(), delimiter=",")))
Ejemplo 2: json a csv python
import pandas as pd
df = pd.read_json (r'C:UsersRonDesktopTestProduct_List.json')
export_csv = df.to_csv (r'C:UsersRonDesktopTestNew_Products.csv', index = None, header=True)
Ejemplo 3: python json de csv
import csv
import json
csvfile = open('file.csv', 'r')
jsonfile = open('file.json', 'w')
fieldnames = ("FirstName","LastName","IDNumber","Message")
reader = csv.DictReader( csvfile, fieldnames)
for row in reader:
json.dump(row, jsonfile)
jsonfile.write('n')
Ejemplo 4: convertir csv a json python
import pandas as pd
df = pd.read_csv (r'Path where the CSV file is savedFile Name.csv')
df.to_json (r'Path where the new JSON file will be storedNew File Name.json')
Ejemplo 5: json a csv
# call csvkit (which is a Python tool) to convert json to csv:
# https://csvkit.readthedocs.io/en/latest/
in2csv data.json > data.csv
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)