Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CSVDataSource<Out>

Source node for CSV files.

Usage

Files are loaded when the model is build. You can force a reset using the reset() function.

Basic Usage

example1.csv

TIME,NAME,X,Y
1,Maxim,0,0
2,Maxim,0,1
3,Maxim,1,1

Implementation

new CSVDataSource("example1.csv", (row: any) => {
 const object = new DataObject(row.NAME);
 const position = new Absolute2DPosition(parseFloat(row.X), parseFloat(row.Y));
 position.timestamp = parseInt(row.TIME);
 object.setPosition(position);
 return new DataFrame(object);
})

Advanced Usage

For more info, please check the csv-parser documentation.

example3.csv

1;Maxim;0;0
2;Maxim;0;1
3;Maxim;1;1

Implementation

new CSVDataSource("example1.csv", (row: any) => {
 const object = new DataObject(row.NAME);
 const position = new Absolute2DPosition(parseFloat(row.X), parseFloat(row.Y));
 position.timestamp = parseInt(row.TIME);
 object.setPosition(position);
 return new DataFrame(object);
}, {
 headers: ["TIME", "NAME", "X", "Y"],
 separator: ";"
})

Type parameters

  • Out: DataFrame

Hierarchy

  • ListSourceNode<Out>
    • CSVDataSource

Index

Constructors

constructor

  • new CSVDataSource<Out>(file: string, rowCallback: (row: any) => Out, options?: Options & SourceNodeOptions): CSVDataSource<Out>
  • Type parameters

    • Out: DataFrame<Out>

    Parameters

    • file: string
    • rowCallback: (row: any) => Out
        • (row: any): Out
        • Parameters

          • row: any

          Returns Out

    • options: Options & SourceNodeOptions = ...

    Returns CSVDataSource<Out>

Properties

graph

graph: GraphShape<any, any>

Graph shape

name

name: string

Name of the node. Does not have to be unique.

Protected options

options: csv.Options & SourceNodeOptions

uid

uid: string

Unique identifier of node.

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

inlets

  • get inlets(): Edge<In>[]
  • Get the incoming edges

    Returns Edge<In>[]

    Incoming edges

inputData

  • get inputData(): Out[]
  • set inputData(inputData: Out[]): any
  • Returns Out[]

  • Parameters

    • inputData: Out[]

    Returns any

model

  • get model(): Model<any, any>
  • Graph this model is part of

    Returns Model<any, any>

    Positioning model

outlets

  • get outlets(): Edge<Out>[]
  • Get the outgoing edges

    Returns Edge<Out>[]

    Outgoing edges

size

  • get size(): number
  • Returns number

source

  • get source(): DataObject
  • Get the source data object

    Returns DataObject

    Source data object

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): CSVDataSource<Out>
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns CSVDataSource<Out>

emit

  • emit(name: string | symbol, ...args: any[]): boolean
  • emit(event: "available"): boolean
  • emit(name: "completed", e: PushEvent): boolean
  • emit(name: "error", e: PushErrorEvent): boolean
  • emit(name: "ready"): boolean
  • emit(name: "destroy"): boolean
  • Parameters

    • name: string | symbol
    • Rest ...args: any[]

    Returns boolean

  • Emit available event

    Parameters

    • event: "available"

      available

    Returns boolean

  • Emit completed event

    Parameters

    • name: "completed"

      completed

    • e: PushEvent

    Returns boolean

  • Emit error

    Parameters

    • name: "error"

      error

    • e: PushErrorEvent

    Returns boolean

  • Node ready

    Parameters

    • name: "ready"

      ready

    Returns boolean

  • Destroy the node

    Parameters

    • name: "destroy"

      destroy

    Returns boolean

emitAsync

  • emitAsync(type: string | symbol, ...args: any[]): Promise<boolean>
  • Parameters

    • type: string | symbol
    • Rest ...args: any[]

    Returns Promise<boolean>

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

getMaxListeners

  • getMaxListeners(): number
  • Returns number

isAvailable

  • isAvailable(): boolean
  • Check if the node is available for accepting push requests

    Returns boolean

    Is the node available to push

isReady

  • isReady(): boolean
  • Returns boolean

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

logger

  • logger(level: string, log: any): void
  • Graph logger

    Parameters

    • level: string

      Logging level

    • log: any

      Message

    Returns void

Protected mergeFrame

  • mergeFrame(frame: DataFrame): Promise<DataFrame>
  • Parameters

    • frame: DataFrame

    Returns Promise<DataFrame>

Protected mergeObject

  • mergeObject(newObject: DataObject, oldObject: DataObject): DataObject
  • Merge an object

    Parameters

    • newObject: DataObject

      New object

    • oldObject: DataObject

      Existing object

    Returns DataObject

    Existing object

off

  • off(event: string | symbol, listener: (...args: any[]) => void): CSVDataSource<Out>
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns CSVDataSource<Out>

on

  • on(name: string | symbol, listener: (...args: any[]) => void): CSVDataSource<Out>
  • on(event: "available", listener: () => void | Promise<void>): CSVDataSource<Out>
  • on(name: "completed", listener: (event: PushEvent) => void | Promise<void>): CSVDataSource<Out>
  • on(name: "error", listener: (event: PushErrorEvent) => void | Promise<void>): CSVDataSource<Out>
  • on(name: "pull", listener: (options?: PullOptions) => void | Promise<void>): CSVDataSource<Out>
  • on(name: "push", listener: (frame: Out, options?: PushOptions) => void | Promise<void>): CSVDataSource<Out>
  • Parameters

    • name: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns CSVDataSource<Out>

  • Event when a node is available

    Parameters

    • event: "available"

      available

    • listener: () => void | Promise<void>

      Event callback

        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns CSVDataSource<Out>

  • Event when a push is completed

    Parameters

    • name: "completed"

      error

    • listener: (event: PushEvent) => void | Promise<void>

      Event callback

        • (event: PushEvent): void | Promise<void>
        • Parameters

          • event: PushEvent

          Returns void | Promise<void>

    Returns CSVDataSource<Out>

  • Event when an error is triggered

    Parameters

    • name: "error"

      error

    • listener: (event: PushErrorEvent) => void | Promise<void>

      Error event callback

        • (event: PushErrorEvent): void | Promise<void>
        • Parameters

          • event: PushErrorEvent

          Returns void | Promise<void>

    Returns CSVDataSource<Out>

  • Event when a data frame is pulled

    Parameters

    • name: "pull"

      receive

    • listener: (options?: PullOptions) => void | Promise<void>

      Event callback

        • (options?: PullOptions): void | Promise<void>
        • Parameters

          • Optional options: PullOptions

          Returns void | Promise<void>

    Returns CSVDataSource<Out>

  • Event when a data frame is push to the node

    Parameters

    • name: "push"

      receive

    • listener: (frame: Out, options?: PushOptions) => void | Promise<void>

      Event callback

        • (frame: Out, options?: PushOptions): void | Promise<void>
        • Parameters

          • frame: Out
          • Optional options: PushOptions

          Returns void | Promise<void>

    Returns CSVDataSource<Out>

onPull

  • onPull(): Promise<Out>
  • Returns Promise<Out>

once

  • once(name: string | symbol, listener: (...args: any[]) => void): CSVDataSource<Out>
  • once(event: "available", listener: () => void | Promise<void>): CSVDataSource<Out>
  • once(name: "completed", listener: (event: PushEvent) => void | Promise<void>): CSVDataSource<Out>
  • once(name: "destroy", listener: () => void | Promise<void>): CSVDataSource<Out>
  • once(name: "build", listener: (builder: GraphBuilder<DataFrame, DataFrame>) => void | Promise<void>): CSVDataSource<Out>
  • once(name: "ready", listener: () => void | Promise<void>): CSVDataSource<Out>
  • Parameters

    • name: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns CSVDataSource<Out>

  • Event when a node is available

    Parameters

    • event: "available"

      available

    • listener: () => void | Promise<void>

      Event callback

        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns CSVDataSource<Out>

  • Event when a push is completed

    Parameters

    • name: "completed"

      error

    • listener: (event: PushEvent) => void | Promise<void>

      Event callback

        • (event: PushEvent): void | Promise<void>
        • Parameters

          • event: PushEvent

          Returns void | Promise<void>

    Returns CSVDataSource<Out>

  • Event called when node is destroyed

    Parameters

    • name: "destroy"

      destroy

    • listener: () => void | Promise<void>

      Event callback

        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns CSVDataSource<Out>

  • Event called when node is build

    Parameters

    • name: "build"

      build

    • listener: (builder: GraphBuilder<DataFrame, DataFrame>) => void | Promise<void>

      Event callback

        • (builder: GraphBuilder<DataFrame, DataFrame>): void | Promise<void>
        • Parameters

          • builder: GraphBuilder<DataFrame, DataFrame>

          Returns void | Promise<void>

    Returns CSVDataSource<Out>

  • Event called when node is ready

    Parameters

    • name: "ready"

      ready

    • listener: () => void | Promise<void>

      Event callback

        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns CSVDataSource<Out>

onceAvailable

  • onceAvailable(): Promise<void>
  • Promise once the node is available

    Returns Promise<void>

    Promise when the node is available

onceCompleted

  • onceCompleted(frameUID: string): Promise<PushEvent>
  • Promise once the frame is completed

    Parameters

    • frameUID: string

      Frame UID

    Returns Promise<PushEvent>

    Promise when the frame is completed

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): CSVDataSource<Out>
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns CSVDataSource<Out>

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): CSVDataSource<Out>
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns CSVDataSource<Out>

pull

  • pull(options?: PullOptions): Promise<void>
  • Send a pull request to the node

    Parameters

    • Optional options: PullOptions

    Returns Promise<void>

    Pull promise

push

  • push(data: Out | Out[], options?: PushOptions): Promise<void>
  • Push data to the node

    Parameters

    • data: Out | Out[]

      Data frame to push

    • Optional options: PushOptions

    Returns Promise<void>

    Push promise

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): CSVDataSource<Out>
  • Parameters

    • Optional event: string | symbol

    Returns CSVDataSource<Out>

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): CSVDataSource<Out>
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns CSVDataSource<Out>

reset

  • reset(): Promise<void>

setMaxListeners

  • Parameters

    • n: number

    Returns CSVDataSource<Out>

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number