mapColumnsToRow

Map a list of columns to rows.

mapColumnsToRow(columns: (Type | null)[], rows: any[][]): Object[]

Example:

import { Types, mapColumnsToRows } from 'react-sheets-import';

const [name, email] = Types.Object({
    name: Types.String(),
    email: Types.String()
});
const columns = [name, null, email];
const rows = [
    ['John', 'Paris', 'john@gmail.com'],
    ['Jane', 'Lyon', 'jane@gmail.com']
];
const users = mapColumnsToRows(columns, rows);

In this example, the city will simply be ignored because it's not mapped to anything (null).

Last updated