Skip to main content
Documents

CSV

CSV

The CSV module is responsible for performing CSV handling actions. Its methods can be accessed as in the example below:

js
const csvRead = await CSV.read["v1_0_0"]({
path: "C:/Users/Roberty/Desktop/teste.csv"
separator: ","
})

Methods

read

Method responsible for reading a CSV file.

js
const csvRead = await CSV.read["v1_0_0"]({
path: "C:/Users/Roberty/Desktop/teste.csv"
separator: ","
})

Required parameters

  • path: String - expects the path of the CSV file that will be read.

Optional parameters

  • separator: String - expects the column separator of the CSV file. Default value: ;.

Return

The constant or variable created, such as the csvRead of the example shown earlier, receives an object with the following properties:

  • values: Array - returns an array with the values of the CSV file.
  • count: Number - returns the number of rows of the CSV file.

getCellValue

Method responsible for getting the value present in a cell of a CSV file.

js
const getCellValue = await CSV.getCellValue["v1_0_0"]({
csvFile: "csv",
row: 1,
column: 1
})

Required parameters

  • csvFile: Object - expects an object returned by the read action.
  • row: Number - expects a number corresponding to the desired row.
  • column: Number - expects a number corresponding to the desired column.

Return

The constant or variable created, such as the getCellValue of the example shown earlier, receives an object with the following properties:

  • value: Any - returns the value of the cell obtained.

setCellValue

Method responsible for setting the value of a cell of a CSV file.

js
await CSV.setCellValue["v1_0_0"]({
csvFile: csvRead,
row: 1,
column: 1,
value: "novo valor"
})

Required parameters

  • csvFile: Object - expects an object returned by the read action.
  • row: Number - expects a number corresponding to the desired row.
  • column: Number - expects a number corresponding to the desired column.
  • value: String - expects the value that will be set in the cell.

Return

This action has no return.