-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgenerator.js
More file actions
34 lines (31 loc) · 849 Bytes
/
generator.js
File metadata and controls
34 lines (31 loc) · 849 Bytes
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
var csv = require('csv');
var fs = require('fs');
var faker = require('faker');
var columns = {
first_name: 'first_name',
last_name: 'last_name',
phone: 'phone',
email: 'email',
city: 'city',
zipcode: 'zipcode',
website: 'website',
company: 'company'
};
function fakeContact() {
return {
first_name: faker.name.firstName(),
last_name: faker.name.lastName(),
phone: faker.phone.phoneNumber(),
email: faker.internet.email(),
city: faker.address.city(),
zipcode: faker.address.zipCode(),
website: faker.internet.domainName(),
company: faker.company.companyName()
};
};
csv.generate({ objectMode: true, seed: 1, columns: columns, length: 50 })
.pipe(csv.transform(function() {
return fakeContact();
}))
.pipe(csv.stringify({ header: true }))
.pipe(fs.createWriteStream('example.csv'));