This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import config from './config.js';
|
||||
|
||||
export async function parseCsv(filePath) {
|
||||
const fs = require('fs').promises; // Use promises version
|
||||
const csv = require('csv-parser');
|
||||
|
||||
const results = [];
|
||||
const stream = fs.createReadStream(filePath).pipe(csv());
|
||||
|
||||
for await (const row of stream) {
|
||||
// Map CSV columns to item properties. Adjust this mapping based on your CSV
|
||||
const item = {
|
||||
productId: row.productId, // Use productId from CSV
|
||||
name: row.name,
|
||||
collectionId: row.collectionId,
|
||||
imageUrl: row.imageUrl
|
||||
// Add other properties as needed
|
||||
};
|
||||
results.push(item);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
Reference in New Issue
Block a user