-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsvtojson.js
18 lines (10 loc) · 2.3 KB
/
csvtojson.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var atob = require('atob');
var encodedCsv = 'U2VyaWVzX3JlZmVyZW5jZQlQZXJpb2QJRGF0YV92YWx1ZQlTdXBwcmVzc2VkCVNUQVRVUwlVTklUUwlNYWduaXR1ZGUJU3ViamVjdAlHcm91cAlTZXJpZXNfdGl0bGVfMQlTZXJpZXNfdGl0bGVfMglTZXJpZXNfdGl0bGVfMwpFQ1RBLlMxOUExCTIwMDEuMDMJCQlDCURvbGxhcnMJNglFbGVjdHJvbmljIENhcmQgVHJhbnNhY3Rpb25zIChBTlpTSUMwNikgLSBFQ1QJVG90YWwgdmFsdWVzIC0gRWxlY3Ryb25pYyBjYXJkIHRyYW5zYWN0aW9ucyBBL1MvVCBieSBkaXZpc2lvbglBY3R1YWwJUlRTIHRvdGFsIGluZHVzdHJpZXMJCkVDVEEuUzE5QTEJMjAwMi4wMwkJCUMJRG9sbGFycwk2CUVsZWN0cm9uaWMgQ2FyZCBUcmFuc2FjdGlvbnMgKEFOWlNJQzA2KSAtIEVDVAlUb3RhbCB2YWx1ZXMgLSBFbGVjdHJvbmljIGNhcmQgdHJhbnNhY3Rpb25zIEEvUy9UIGJ5IGRpdmlzaW9uCUFjdHVhbAlSVFMgdG90YWwgaW5kdXN0cmllcwkKRUNUQS5TMTlBMQkyMDAzLjAzCQkJQwlEb2xsYXJzCTYJRWxlY3Ryb25pYyBDYXJkIFRyYW5zYWN0aW9ucyAoQU5aU0lDMDYpIC0gRUNUCVRvdGFsIHZhbHVlcyAtIEVsZWN0cm9uaWMgY2FyZCB0cmFuc2FjdGlvbnMgQS9TL1QgYnkgZGl2aXNpb24JQWN0dWFsCVJUUyB0b3RhbCBpbmR1c3RyaWVzCQpFQ1RBLlMxOUExCTIwMDQuMDMJMjgwMDUuMQkJRglEb2xsYXJzCTYJRWxlY3Ry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W5zYWN0aW9ucyBBL1MvVCBieSBkaXZpc2lvbglBY3R1YWwJUlRTIHRvdGFsIGluZHVzdHJpZXMJCg==';
var decodedCsv = atob(encodedCsv);
decodedCsv = decodedCsv.split('\n');
var json = {};
for(var i = 0; i < decodedCsv.length ; i++) {
var innerData = decodedCsv[i].split('\t');
json.collection += JSON.stringify(innerData);
}
console.log(json);