Skip to content

Join-like methods #18

@Dam-Buty

Description

@Dam-Buty

The use case is to be able to "join" the rows from a CSV to the rows from another array of objects, using a column of each collection to determine identity.

For example :

const enrichedRows = await withCSV("").columns(["id"]).leftJoin(arrayOfObjects, { on: { left: "id", right: "uid" } })

// Alternative with a callback
const enrichedRows = await withCSV("").columns(["id"]).leftJoinBy(arrayOfObjects, (row, arrayOfObjects) => {
  return arrayOfObjects.find(object => object.uid === row.id)
})

// Also innerJoin and rightJoin variants

====

Another use case is to be able to map the value of a column to a line from a correspondance table :

const categoryNames = {
  FSN: "Fashion",
  SPT: "Sport",
  RCK: "Rock'n'roll baby"
}

const enrichedRows = await withCSV("").columns(["id", "name", "categoryId"]).mapKey("categoryId", categoryNames)

// Also mapKeyBy variant that takes a callback

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions