17 lines
536 B
JavaScript
17 lines
536 B
JavaScript
const XLSX = require('xlsx');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const csvPath = path.join(__dirname, '..', 'public', 'horaires_example.csv');
|
|
const outPath = path.join(__dirname, '..', 'public', 'horaires_example.xlsx');
|
|
|
|
if (!fs.existsSync(csvPath)) {
|
|
throw new Error(`CSV example not found: ${csvPath}`);
|
|
}
|
|
|
|
const csvContent = fs.readFileSync(csvPath, 'utf8');
|
|
const workbook = XLSX.read(csvContent, { type: 'string', raw: false, FS: ',' });
|
|
XLSX.writeFile(workbook, outPath);
|
|
console.log('Wrote', outPath);
|
|
|