Files
tilbudgivern/test_csv_parser.js
T
alexpolo1 d4d3eb3d00 feat: Implement Bygma Prisbog import script to handle CSV import of 54,558 products
feat: Create Python script to scrape 10 installation manuals from Bygma, focusing on construction materials

feat: Develop script to scrape installation manual from Bygma by VareNr, including AI analysis and database storage

feat: Add script to scrape Swedoor Snap-In Karmsat installation manual using product name from URL

chore: Create start script for PM2 to manage services with correct node path

test: Add comprehensive test script for quote generation and PDF endpoints

test: Implement CSV parser tests to verify product presence and data integrity

test: Create readline test script to efficiently read and search for product in CSV
2025-10-26 08:15:46 +00:00

40 lines
1.2 KiB
JavaScript

const fs = require('fs');
const csv = require('csv-parser');
const CSV_PATH = '/mnt/HC_Volume_103713257/tilbudgivern/frontend/firmadata/subvendor/bygma/PrisBog_CLEANED.csv';
let lineCount = 0;
let found118266 = false;
console.log('📊 Scanning CSV with csv-parser...\n');
fs.createReadStream(CSV_PATH)
.pipe(csv({
separator: ';',
headers: ['Varegrp', 'VareNr', 'Tekst', 'Enhed', 'BruttoPris', 'Opdat', 'Nettopris', 'DB-nr', 'EAN-nr', 'Std'],
skipLinesWithError: true,
strict: false,
skipEmptyLines: true
}))
.on('data', (row) => {
lineCount++;
if (row.VareNr && row.VareNr.replace(/\s+/g, '').trim() === '118266') {
found118266 = true;
console.log(`✅ FOUND 118266 at line ${lineCount}!`);
console.log('Data:', row);
}
if (lineCount % 10000 === 0) {
console.log(`Processed ${lineCount} lines...`);
}
})
.on('end', () => {
console.log(`\n📊 Total lines parsed: ${lineCount}`);
console.log(`Product 118266 found: ${found118266 ? 'YES ✅' : 'NO ❌'}`);
})
.on('error', (error) => {
console.error('❌ Error:', error.message);
console.log(`Stopped at line ${lineCount}`);
});