Sifa professional network frontend (Next.js, React, TailwindCSS) sifa.id/
at main 21 lines 727 B view raw
1import JSZip from 'jszip'; 2 3/** 4 * Extract CSV files from a LinkedIn data export ZIP. 5 * Returns a map of filename -> CSV content string. 6 * LinkedIn ZIPs may have nested paths; we strip directories and use only the filename. 7 */ 8export async function extractLinkedInZip(file: File): Promise<Map<string, string>> { 9 const zip = await JSZip.loadAsync(file); 10 const csvFiles = new Map<string, string>(); 11 12 for (const [name, entry] of Object.entries(zip.files)) { 13 if (name.endsWith('.csv') && !entry.dir) { 14 // Extract just the filename (LinkedIn ZIPs may have nested paths) 15 const fileName = name.split('/').pop() ?? name; 16 csvFiles.set(fileName, await entry.async('text')); 17 } 18 } 19 20 return csvFiles; 21}