csv

package
v0.55.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package csv provides a CSV parser for k6.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModuleInstance

type ModuleInstance struct {
	*RootModule
	// contains filtered or unexported fields
}

ModuleInstance represents an instance of the fs module for a single VU.

func (*ModuleInstance) Exports

func (mi *ModuleInstance) Exports() modules.Exports

Exports implements the modules.Module interface and returns the exports of our module.

func (*ModuleInstance) NewParser

func (mi *ModuleInstance) NewParser(call sobek.ConstructorCall) *sobek.Object

NewParser creates a new CSV parser instance.

func (*ModuleInstance) Parse

func (mi *ModuleInstance) Parse(file sobek.Value, options sobek.Value) *sobek.Promise

Parse parses the provided CSV file, and returns a promise that resolves to a shared array containing the parsed data.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser is a CSV parser.

func (*Parser) Next

func (p *Parser) Next() *sobek.Promise

Next returns the next row in the CSV file.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader is a CSV reader.

It wraps a csv.Reader and provides additional functionality such as the ability to stop reading at a specific line.

func NewReaderFrom

func NewReaderFrom(r io.Reader, options options) (*Reader, error)

NewReaderFrom creates a new CSV reader from the provided io.Reader.

It will check whether the first line should be skipped and consume it if necessary. It will also check whether the reader should start from a specific line and skip lines until that line is reached. We perform these operations here to avoid having to do them in the Read method.

Hence, this constructor function can return an error if the first line cannot be skipped or if the reader cannot start from the specified line.

func (*Reader) Read

func (r *Reader) Read() ([]string, error)

type RootModule

type RootModule struct {
	// contains filtered or unexported fields
}

RootModule is the global module instance that will create instances of our module for each VU.

func New

func New() *RootModule

New returns a pointer to a new RootModule instance.

func (*RootModule) NewModuleInstance

func (rm *RootModule) NewModuleInstance(vu modules.VU) modules.Instance

NewModuleInstance implements the modules.Module interface and returns a new instance of our module for the given VU.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL