Created
October 7, 2016 21:25
-
-
Save openhoat/8fcc42c3fa034ad72721106e44bb0aeb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| const _ = require('lodash'); | |
| const hat = require('hat'); | |
| const homeDir = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME']; | |
| const src = path.join(homeDir, 'actifs.res'); | |
| const dest1 = path.join(homeDir, 'actifs.res.out1'); | |
| const dest2 = path.join(homeDir, 'actifs.res.out2'); | |
| const content = _.compact(_.tail(fs.readFileSync(src, 'utf8').split('\n'))); | |
| const data = content.map(line => { | |
| const parts = line.split(/[\s]+/); | |
| return {userid: parts[0], email: parts[1], uid: hat()}; | |
| }); | |
| fs.writeFileSync(dest1, ['userid uid'].concat(data.map(item => [item.userid, item.uid].join('\t'))).join('\n')); | |
| fs.writeFileSync(dest2, ['uid email'].concat(data.map(item => [item.uid, item.email].join('\t'))).join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment