-
Notifications
You must be signed in to change notification settings - Fork 1
/
getAddressFromCsv.js
39 lines (33 loc) · 1.01 KB
/
getAddressFromCsv.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
const fs = require('fs');
const path = require('path');
const csv = require('csv-parser');
const accountsDirectory = 'accounts'; // 替换为你的 accounts 目录路径
const addressArray = [];
fs.readdir(accountsDirectory, (err, files) => {
if (err) {
console.error('Error reading directory:', err);
return;
}
files.forEach((file) => {
const filePath = path.join(accountsDirectory, file);
fs.createReadStream(filePath)
.pipe(csv())
.on('data', (row) => {
// console.log(row)
if (row.Address) {
addressArray.push(row.Address);
}
})
.on('end', () => {
// console.log(`Processed file: ${file}`);
// console.log(addressArray)
fs.writeFile('./address.json', JSON.stringify(addressArray, null, 2), (err) => {
if (err) {
// console.error('Error writing JSON file:', err);
return;
}
// console.log('JSON file has been saved.');
});
});
});
});