convcsv2json
1.0.0
将CSV文件转换为基于CSV标头的JSON格式
pip install convcsv2json from convcsv2json import csv2json
data = csv2json (
'sample.csv' , # CSV filename
intend = 4 , # JSON intendation
numbered = True # Set JSON data in numbered format or not
)
print ( data . json ()) # Print in JSON format
data . export ( 'export.json' ) # Export the data into a JSON file "intend" and "numbered" parameters are optional. By default, "intend" is set as None and "numbered" is set as False
from convcsv2json import csv2json
print ( csv2json ( 'sample.csv' , 4 ). json ()) name,age
kewldog,12
kewlcat,23
[
{
"name" : " kewldog " ,
"age" : " 12 "
},
{
"name" : " kewlcat " ,
"age" : " 23 "
}
]