DeveloperBreeze

Convert Array of Objects to CSV

// Example data as an array of objects
const data = [
    { name: 'John', age: 30, city: 'New York' },
    { name: 'Alice', age: 25, city: 'San Francisco' },
    { name: 'Bob', age: 35, city: 'Los Angeles' }
];

// Convert array of objects to CSV format
const csvContent = data.map(obj => Object.values(obj).join(',')).join('\\n');

// Log the generated CSV content to the console
console.log('CSV Content:', csvContent);

Continue Reading

Handpicked posts just for you — based on your current read.

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!