Skip to content

Commit

Permalink
price qr code generator tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeni committed Apr 28, 2019
1 parent 49f5847 commit e762b98
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ addresses.txt
node_modules
generated*
*.svg
wallets*
wallets*
pricelist
41 changes: 41 additions & 0 deletions generatePriceQR.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const qr = require('qr-image');
const csv = require('csv-parser');
const fs = require('fs');

const URL = "https://sundai.io"
const priceList = 'pricelist-ws.csv';
const folder = 'pricelist';
const workDir = process.cwd();

async function run() {
const prices = [];

fs.createReadStream(`${workDir}/${folder}/${priceList}`)
.pipe(csv())
.on('data', (row) => {
prices.push(row);
})
.on('end', async () => {
console.log(prices);
let priceLink;
let address;
let price;
let item;
let event;
let priceQR;
for(let i = 0; i < prices.length; i++) {
event = prices[i].event;
address = prices[i].address;
price = prices[i].price;
item = prices[i].item;
priceLink = `${URL}/${address};${price};${item}`;
priceQR = qr.image(priceLink, { type: 'png' });
priceQR.pipe(require('fs').createWriteStream(`${folder}/${event}_${address.substring(0,8)}_${item}.png`));
}
});
}

run();



0 comments on commit e762b98

Please sign in to comment.