diff --git a/.gitignore b/.gitignore index 012726e..b70bd77 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ addresses.txt node_modules generated* *.svg -wallets* \ No newline at end of file +wallets* +pricelist \ No newline at end of file diff --git a/generatePriceQR.js b/generatePriceQR.js new file mode 100644 index 0000000..40d4fb4 --- /dev/null +++ b/generatePriceQR.js @@ -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(); + + +