var csvToJson = require('convert-csv-to-json');
var fileInputName = 'Bangalore_schools.csv';
var fileOutputName = 'output.json';
csvToJson.generateJsonFileFromCsv(fileInputName, fileOutputName);
Csv File Link: Csv File
But the above code i have used i am unable to fully convert it to json. Please help. Output is coming like this.. i want to separate each key and its value likewise we have in json.
[
{
"district|block|cluster|schoolid|schoolname|category|gender|medium_of_inst|address|area|pincode|landmark|identification1|busroutes|identification2|latlong": "-----------+---------+----------------------------+----------+-------------------------------------------+---------------+--------+----------------+---------------------------------------------------------------------------------------------------------------+-----------------------------------------+------------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-------------------------------------------+-----------------------------------------------------------------------------------------------------+------------------------------------------"
},
{
"district|block|cluster|schoolid|schoolname|category|gender|medium_of_inst|address|area|pincode|landmark|identification1|busroutes|identification2|latlong": " bangalore|south-1|vajara halli|32868|GKHPS ALAHALLI|Upper Primary|co-ed|kannada|avalahalli south range- 1|bangalore|560062|masjid||||POINT(77.5766623020172 12.8893003120716)"
},
The default delimiter convert-csv-to-json
uses is a semicolon ( ;
). If you want to use a different delimiter, like |
the file you shared uses, you need to define it explicitly. Eg:
csvToJson.fieldDelimiter('|').generateJsonFileFromCsv(fileInputName, fileOutputName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.