-
Notifications
You must be signed in to change notification settings - Fork 0
Csv
Ƭ CsvEncoding: "utf8" | "windows1252"
• defaultParseOptions: Object
| Name | Type |
|---|---|
columns |
boolean |
delimiter |
string |
skip_empty_lines |
boolean |
• defaultWriteOptions: Object
| Name | Type |
|---|---|
delimiter |
string |
quoted_empty |
boolean |
quoted_string |
boolean |
▸ readCSV<T, P>(fileName, encoding?, options?): P extends { columns: false } ? Primitives[][] : T[]
Read a CSV file and return an array of objects. The Key Names a taken from the first line of the CSV.
Test
| Name | Type |
|---|---|
T |
extends CsvRow<T> |
P |
extends Options
|
| Name | Type | Default value | Description |
|---|---|---|---|
fileName |
string |
undefined |
|
encoding |
CsvEncoding |
"utf8" |
|
options? |
P & Options
|
undefined |
Options used to parse the CSV file. Provided keys override the default ones. {@link parse.Options}, defaultParseOptions |
P extends { columns: false } ? Primitives[][] : T[]
▸ readCSVAsync<T>(fileName, options?): Promise<T[]>
deprecated
| Name | Type |
|---|---|
T |
extends CsvRow<T> |
| Name | Type |
|---|---|
fileName |
string |
options? |
Options |
Promise<T[]>
▸ toMap<T, K>(records, keyName): Map<T[K], T>
Create a map from an array of Objects. The key is taken from the objects based on the provided keyname.
| Name | Type |
|---|---|
T |
T |
K |
extends string | number | symbol
|
| Name | Type | Description |
|---|---|---|
records |
T[] |
|
keyName |
K |
Schlüssel -> Optimalerweise die Artikelnummer |
Map<T[K], T>
▸ writeCSV(inputArray, path, deleteCsvIfEmpty, encoding?, options?): Promise<void>
Writes an array of arrays / rows as a csv file.
| Name | Type | Description |
|---|---|---|
inputArray |
Primitives[][] |
Array of Rows. Please make sure, that all rows have the same amount of elements. |
path |
string |
Where to write the csv file? |
deleteCsvIfEmpty |
boolean |
Delete any existing csv file, if the provided array has a length of 0. Alternatively the function will throw an exception if you provide an empty inputArray. |
encoding? |
CsvEncoding |
|
options? |
Options |
- |
Promise<void>
▸ writeCSVFromArray<T>(inputArray, path, deleteCsvIfEmpty?, encoding?, options?): Promise<void>
/** Writes an array of objets as a csv file. This function extracts the column names from the key of the first object. The Data is gathered from all Objects including the frist one.
| Name | Type |
|---|---|
T |
extends CsvRow<T> |
| Name | Type | Default value | Description |
|---|---|---|---|
inputArray |
Required<T>[] |
undefined |
Array of Objects. |
path |
string |
undefined |
writeCSV |
deleteCsvIfEmpty |
boolean |
false |
writeCSV |
encoding? |
CsvEncoding |
undefined |
|
options? |
Options |
undefined |
Promise<void>
▸ writeCSVFromMap<T>(inputMap, path, deleteCsvIfEmpty, encoding?, options?): Promise<void>
Writes a Map of objets to a csv file. This function extracts the column names from the key of the first object. The Data is gathered from all Objects including the frist one.
| Name | Type |
|---|---|
T |
extends CsvRow<T> |
| Name | Type | Description |
|---|---|---|
inputMap |
Map<any, Required<T>> |
Map of Objects. |
path |
string |
writeCSV |
deleteCsvIfEmpty |
boolean |
writeCSV |
encoding? |
CsvEncoding |
- |
options? |
Options |
- |
Promise<void>