Last updated

API / geotoolkit / data / CSVWriter / CSVWriter

Class: CSVWriter

data.CSVWriter.CSVWriter

Class defines CSVWriter for datatable or Array. 'stream' defines instance of IWritable. It must be passed as parameter to write to stream. User can provide their own stream or use stream such as TextStream.

Example

import {CSVWriter} from '@int/geotoolkit/data/CSVWriter';
import {TextStream} from '@int/geotoolkit/util/stream/TextStream';
...
new CSVWriter({
'stream': new TextStream({
'filename': 'csvfile.csv',
'type': 'text/csv',
'save': true
})
})
.writeTable(table, {
'includeHeaders': true
})
.close();

Table of contents

Constructors
Methods

Contents

Constructors

new CSVWriter(options)

new CSVWriter(options)

Parameters

Name Type
optionsOptions
Methods

close

close(): CSVWriter

Closes writer. It is necessary to close the writer in order to save and stream

Returns

CSVWriter


getClassName

getClassName(): string

Returns

string


getOptions

getOptions(): Required<Options>

Get Options

Returns

Required<Options>

options see CSVWriter.setOptions


setOptions

setOptions(options): CSVWriter

Set options for writer

Parameters

Name Type Description
optionsOptionsoptions

Returns

CSVWriter


writeRow

writeRow(row): CSVWriter

Write a row to stream

Parameters

Name Type Description
rowstring[]row

Returns

CSVWriter


writeRows

writeRows(rows, maxBuffer?): CSVWriter

Write array of rows to stream

Parameters

Name Type Description
rowsstring[][]array of rows
Optional maxBuffernumbermaxBuffer maxRows to save in memory before writing to stream

Returns

CSVWriter


writeTable

writeTable(datatable, options?): CSVWriter

write Datatable to stream

Parameters

Name Type Description
datatableAbstractDataTableDataTable or DataTableView to write
Optional optionsWriteOptionsoptions

Returns

CSVWriter


writeText

writeText(text, eol?): CSVWriter

Write text to stream

Parameters

Name Type Description
textstringtext
Optional eolbooleanindicate if it's end of line

Returns

CSVWriter


getClassName

Static getClassName(): string

Returns

string