-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
74 lines (70 loc) · 1.5 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const async = require('async')
let lmcsv = require("./index.js")
let csv = new lmcsv("test.csv")
let myobj = [{
"id": 1,
"first_name": "Hartley",
"last_name": "Mulvenna",
"email": "[email protected]",
"gender": "Male",
"ip_address": "6.25.240.135",
"hobbies": ["fishing", "camping", "hiking"]
}, {
"id": 2,
"first_name": "Antonio",
"last_name": "Pigne",
"email": "[email protected]",
"gender": "Male",
"ip_address": "102.234.210.24",
"hobbies": ["bowling", "music"],
"farm animals":{
"pigs":3,
"cows":{
"male":2,
"female":1
},
"horses":1
}
}, {
"id": 3,
"first_name": "Gamaliel",
"last_name": "Graser",
"email": "[email protected]",
"SAT score": 1420
}, {
"id": 4,
"first_name": "Celestyna",
"last_name": "Pawels",
"email": "[email protected]",
"gender": "Female",
"ip_address": "18.17.253.197",
"age": 22
}, {
"id": 5,
"first_name": "Mommy",
"last_name": "Caitlin",
"email": "[email protected]",
"gender": "Female",
"ip_address": "213.145.160.242"
}, {
"id": 6,
"first_name": "Nettle",
"last_name": "Mordey",
"email": "[email protected]",
"gender": "Female",
"ip_address": "178.58.2.233",
"occupation":"Engineer"
}]
//
async.eachSeries(myobj, function eachRow(row, cb) {
csv.writeRow(row, function(err) {
if (err) return cb(err)
return cb(null)
})
}, function endEachRow(err) {
if (err) throw err
console.log("done")
})
// csv.writeRowArray(myobj, function(err){
// console.log('done')
// })