forked from MyEtherWallet/ethereum-lists
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateCSV.js
More file actions
29 lines (26 loc) · 756 Bytes
/
generateCSV.js
File metadata and controls
29 lines (26 loc) · 756 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
const fs = require('fs');
const ethTokens = require('./dist/tokens/eth/tokens-eth.min.json');
function generate() {
const headers = Object.keys(ethTokens[0]).filter(itm => {
if (itm === 'name' || itm === 'symbol' || itm === 'address') return itm;
});
const csv = ethTokens.map(item => {
const arr = [];
headers.forEach(head => {
arr.push(item[head]);
});
return arr.join(',');
});
csv.unshift(headers.join(','));
const returnableCsv = csv.join('\r\n');
fs.writeFileSync('./generatedEthCSV.csv', returnableCsv, 'utf8', function(
err
) {
if (err) {
console.log('Something went wrong! File cannot be generated!');
} else {
console.log('CSV created succesfully!');
}
});
}
generate();