Module: csv-reader

This module parses csv files into insertion queries
Version:
  • 0.0.2
Author:
  • Alessandro Amantini

Methods


<inner> arrayToString(array:, separator:, before:, after:)

Take an array and convert it into a string. Put the 'before' and 'after' characters around each element and separate them using the 'separator' character. By default, separator is a comma ",", whereas 'before' and 'after' are both a single quote "'".
Parameters:
Name Type Description
array: Array.<Object> array to be converted into a string
separator: string the character between each element. By default is a comma
before: string the character preceding each element. By default a single quote
after: string the character next each element. By default a single quote

<inner> convert(csvFilePath:, insertSqlFile:)

Take the path of a csv file, parse it, and put into the insertion sql file passed as path
Parameters:
Name Type Description
csvFilePath: string the path of the csv file
insertSqlFile: string path of the insert sql file

<inner> generateInsertionQuery(tableName:, fields:, value:, insertSqlFile:)

Take the name of the database table and fields, plus some entries and covert them all into an insertion query.
Parameters:
Name Type Description
tableName: string the name of the database table
fields: string the name of the database columns
value: string an entry as string respecting the order dictated by 'records'
insertSqlFile: string path of the insert sql file

<inner> getJSONKeys(object:)

Take a csv as JSON and return the title of the table and the records names. In order to work, the title has to be the very first column in the csv.
Parameters:
Name Type Description
object: JSON the JSON to collect the names from
Returns:
: table name and record names as, respectively, tableName and recordNames
Type
JSON

<inner> getJSONValues(object:, keys:)

Take a JSON and return the values contained as an array. Only the values contained in the variable 'keys' will be parsed.
Parameters:
Name Type Description
object: JSON the JSON to collect the values from
keys: Array.<string> the JSON keys
Returns:
: the values as an array
Type
Array.<string>