type RowObject = { [key: string]: string | null }; export function getJsonFromHeadersHelper(values: string[][]): RowObject[] { if (!values || values.length === 0) { throw new Error('The input data is empty or undefined.'); } const headers = values[0]; // First row as headers const dataRows = values.slice(1); // Remaining rows as data // Transform rows into JSON objects return dataRows.map((row) => { const rowObject: RowObject = {}; headers.forEach((header, index) => { rowObject[header] = row[index] || null; // Default to null for missing or undefined values }); return rowObject; }); }