From e1004215e1f8ecdb36bf58c508682b7f6bacec3b Mon Sep 17 00:00:00 2001 From: ewin Date: Tue, 12 Aug 2025 18:49:30 -0400 Subject: [PATCH] log index; add variable to resume partway through the list --- bin/one-time/hrothgar-viera-headwear | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/one-time/hrothgar-viera-headwear b/bin/one-time/hrothgar-viera-headwear index 4071654..25aa6bb 100755 --- a/bin/one-time/hrothgar-viera-headwear +++ b/bin/one-time/hrothgar-viera-headwear @@ -15,21 +15,26 @@ const mw = await getMediawikiClient(); // parse CSV, naively assume there are no quotes or backslashes (because i checked) const data = readFileSync(join(import.meta.dirname, '../../hats.csv'), 'utf-8').split(/\r?\n/g).map(line => line && line.split(',')); -console.log(data.slice(0, 1)); const headers = data.splice(0, 1)[0]; const COL_ITEM = headers.findIndex(field => field.toLowerCase() === 'item'); const COL_VIERA = headers.findIndex(field => field.toLowerCase().includes('viera')); const COL_HROTH = headers.findIndex(field => field.toLowerCase().includes('hrothgar')); +const start = parseInt(process.env.START ?? '0', 10); +if (start) { + console.log('Starting from item index', start); + data.splice(0, start); +} + console.log('Processing', data.length, 'items'); -for (const line of data) { +for (const [i, line] of Object.entries(data)) { const item = line[COL_ITEM]; const params = { 'display-on-viera': line[COL_VIERA].toLowerCase() === 'yes' ? 'y' : 'n', 'display-on-hrothgar': line[COL_HROTH].toLowerCase() === 'yes' ? 'y' : 'n', } - console.log(item, params); + console.log(+i + start, 'of', data.length + start, item, params); // read and apply updates const pageContent = await mw.readPage(item);