API / geotoolkit / 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();Constructors
Methods
▸ close(): CSVWriter
Closes writer. It is necessary to close the writer in order to save and stream
▸ getClassName(): string
string
▸ getOptions(): Required<Options>
Get Options
Required<Options>
options see CSVWriter.setOptions
▸ setOptions(options): CSVWriter
Set options for writer
| Name | Type | Description |
|---|---|---|
options | Options | options |
▸ writeRow(row): CSVWriter
Write a row to stream
| Name | Type | Description |
|---|---|---|
row | string[] | row |
▸ writeRows(rows, maxBuffer?): CSVWriter
Write array of rows to stream
| Name | Type | Description |
|---|---|---|
rows | string[][] | array of rows |
Optional maxBuffer | number | maxBuffer maxRows to save in memory before writing to stream |
▸ writeTable(datatable, options?): CSVWriter
write Datatable to stream
| Name | Type | Description |
|---|---|---|
datatable | AbstractDataTable | DataTable or DataTableView to write |
Optional options | WriteOptions | options |
▸ writeText(text, eol?): CSVWriter
Write text to stream
| Name | Type | Description |
|---|---|---|
text | string | text |
Optional eol | boolean | indicate if it's end of line |
▸ Static getClassName(): string
string