CSV Parsing
Newgate includes a robust CSV parser that activates when Content-Type: text/csv is detected.
Usage
app.post('/upload-csv', (req, res) => {
// req.body is an array of objects
const rows = req.body;
rows.forEach(row => {
console.log(row);
});
res.json({ count: rows.length });
});
Options
The CSV parser supports various options for configuration.
const options = {
headers: true, // Use first row as headers (default: true)
delimiter: ',', // Field delimiter (default: ',')
skipEmptyLines: true, // Skip empty lines (default: true)
schema: { // Optional schema validation
age: (val) => !isNaN(parseInt(val))
}
};
Last updated: 12/11/2025
Edit on GitHub