Skip to main content
Version: v0.0.4

Function: parseCsvSource()

parseCsvSource(source): object

Parse a CsvSource into concepts and skipped-row warnings.

Parameters

source

CsvSource

The CSV source.

Returns

object

The parsed concepts (by code) and the load warnings.

concepts

concepts: Map<string, Concept>

warnings

warnings: LoadWarning[]

Throws

TERM_CODESYSTEM_MALFORMED when the file has no header row, or a configured code/display/status/property column is absent from the header.

Example

import { parseCsvSource } from "@cosyte/terminology";

const { concepts } = parseCsvSource({
format: "csv",
content: "CODE,NAME\n2160-0,Creatinine",
columns: { code: "CODE", display: "NAME" },
});
concepts.get("2160-0")?.display; // => "Creatinine"