WILCO
  • 👩‍🎓User Manual
    • USER MANUAL
      • welcome page
        • create an account
        • login
          • login troubleshooting
        • logout
      • landing page
      • fleet dashboards
        • URL
        • fleet header
        • fleet
        • current alerts
        • map
      • aircraft timeline
        • overview
        • timeline header
          • calendar
          • warnings
          • show cleared
          • show hidden
        • tags
        • custom message
      • dashboards
        • overview
        • header
        • dashboard
        • parameters
          • search parameter
          • plot graph
          • trend chart
      • open a ticket
    • DESIGNER USER MANUAL
      • Manual post
        • copy text
        • upload file
          • CSV insertion
          • elasticsearch aggregation
      • Edit layouts
        • type of layouts
        • manage layouts and uplinks
        • create layout
          • report parser
          • web connector
        • IFT at Layout
      • Edit Fault codes
        • IFT at Fault Code
      • Edit parameters
        • IFT at Parameter
      • Edit Dashboards
        • create new dashboard
        • edit dashboard
        • Dashboards
          • Dashboard drawing tips
            • Illustrator
          • Dashboard rules
            • Libraries
            • Variables
            • Utils
            • Debugging the rules
            • Graphs
              • creation of the graph
              • Set the title of the graph
              • draw some zones
              • draw a serie (curve)
              • draw horizontal line
              • draw vertical line
              • draw circles
              • Example
            • WILCO.alertWarning
              • WILCO.alertInfo
            • WILCO.alertError
            • WILCO.api
            • WILCO.user
            • WILCO.getEventsForFwot
            • WILCO.getEventsForFwotMinMaxDate
            • WILCO.getSamplesForFwot
            • WILCO.getSamplesForFwotMinMaxDate
            • WILCO.getSampleTableForFwot
            • WILCO.getSamplesTableForFwotMinMaxDate
            • WILCO.getEventsStats
            • WILCO.dsv
            • WILCO.uplink
      • Edit Trends
        • create new trend
        • edit trend
        • Trends
          • Use the tags
          • Access to the surrounding values
      • Edit IFTs
        • edit IFT
        • create an IFT
        • IFT V2
          • moment
          • underscore
          • current Fwot
          • Samples
          • FW.api
          • FW.getWilcoUrls
          • FW.http
          • FW.getEvent
          • FW.getOtherEvent
          • FW.getEvents
          • FW.getFwot
          • FW.getFwots
          • FW.notify <deprecated>
          • FW.notifyWithTemplate <deprecated>
          • FW.email
          • FW.setFrom
          • FW.setTo
          • FW.setTitle
          • FW.setVisible
          • FW.setSeverity
          • FW.setComputedDate
          • FW.setStyle
          • FW.getSamples
          • FW.report
          • FW.reportInfo
          • FW.reportWarn
          • FW.reportFault
          • FW.reportError
          • FW.log
          • FW.updateProperties
          • FW.setFlightStatus
          • FW.setLoc
          • FW.uplink
          • FW.set
          • FW.updateSomeFwotProperty
          • FW.updateFwotProperty
          • FW.removeFwotProperty
          • FW.removeSomeFwotProperty
          • FW.tag
          • FW.untag
          • FW.postEvent
          • FW.reportFaultCode
          • FW.querySamples
          • FW.getRaw
          • FW.getBit
          • FW.csv
          • FW.machineLearningPredict
          • FW.webhook
          • FW.getPlugins()
          • FW.json
      • Show Uplinks
      • General Conf
        • Assets
          • Fwots
        • Configuration
          • Constants
          • Docs
          • Event tables
            • Tables
              • JSON structure
                • Title
                • filters
                • cols
                  • Fields of a column
                • Example
      • examples
        • flow of the data
        • use Constants
        • use Doc
        • use EventTable
        • use algorithm on trends
      • Code snippets
        • Get the last UPLINK message with filters
        • Automatically handle faultcodes according to a doc and a regex
        • Get the current airport
        • goto a page from a dashboard
        • get the samples and events over the 3 last legs
        • Webhooks: Get data from typeform and post it to ELK
        • Download a file from a SVG click
        • Clone a SVG template with D3
        • Cheat sheet
    • ADMIN USER MANUAL
      • General Conf
        • Access rights
          • API keys
          • Users
        • Assets
          • Airlines
          • Fwot types
          • Fwots
        • Configuration
          • App configs
            • UPLINK_ROUTING
            • SEND_MAIL
            • DO_UPLINK
            • UPLINK_PATH
            • MAX_DAYS_WITHOUT_EVENTS
            • ACARS_RECIPIENT
            • MAIL_TEMPLATE
            • USE_CURRENT_DATE
            • DO_UPLINK_AUTOMATIC_BLACKLIST
            • DO_UPLINK_MANUAL_BLACKLIST
            • UPLINK_EXPIRATION_MINUTES
          • Bookmarks
          • Constants
          • Docs
          • Event tables
          • Plugins
        • Swiss knife
      • Edit Plugins
        • Commit plugin
        • Deploy plugin
    • Q&A
  • 🔌Plugins
    • fw.ata49
      • Minimum requirements
      • Configuration
    • fw.fuelsave
      • Minimum requirements
      • Configuration
    • fw.opticooling
      • Minimum requirements
      • Configuration
    • fw.taxi
      • Minimum requirements
      • Configuration
    • fw.turnaround
Powered by GitBook
On this page

Was this helpful?

  1. User Manual
  2. DESIGNER USER MANUAL
  3. Edit IFTs
  4. IFT V2

FW.csv

async FW.csv(doc, options) // Reads a CSV Doc (documents stored in WILCO (admin/docs)

This function fetches the document passed in parameter and maps it to an array of objects (within a promise). The document can be referenced by its ID or its name.

Note that it cannot be the ref (plugin-componentXid) because the doc can be overrided for each airline. The name only is sufficient. NB: the name is the component XID

The result is an array of object. Each object represents each line. Each line is a key/value. The key is by default the first line element. And the value is the cell of the current line.

for example,

A

B

TOTO

AZERTY

TATA

QUERTY

would be represented like this:

const docByName = await FW.csv(65257)
//docByName= 
[
{A:'TOTO', B:'AZERTY'},
{A:'TATA', B:'QUERTY'},
]
//reads a doc which separator is ;
const docByName = await FW.csv('THE_DOC_NAME', {delimiter:';'});
//reads a doc which separator is tab
const docById = await FW.csv(2375267, {delimiter:'\t'});

The method does its best to find the correct delimiter, but it is always better to pass it explicitely as above

More generally, the options is an object that can take those properties:

  • output: The format to be converted to. "json" (default) -- convert csv to json. "csv" -- convert csv to csv row array. "line" -- convert csv to csv line string

  • delimiter: delimiter used for separating columns. Use "auto" if delimiter is unknown in advance, in this case, delimiter will be auto-detected (by best attempt). Use an array to give a list of potential delimiters e.g. [",","|","$"]. default: ","

  • quote: If a column contains delimiter, it is able to use quote character to surround the column content. e.g. "hello, world" won't be split into two columns while parsing. Set to "off" will ignore all quotes. default: " (double quote)

  • trim: Indicate if parser trim off spaces surrounding column content. e.g. " content " will be trimmed to "content". Default: true

  • checkType: This parameter turns on and off whether check field type. Default is false. (The default is true if version < 1.1.4)

  • ignoreEmpty: Ignore the empty value in CSV columns. If a column value is not given, set this to true to skip them. Default: false.

  • flatKeys: Don't interpret dots (.) and square brackets in header fields as nested object or array identifiers at all (treat them like regular characters for JSON field identifiers). Default: false.

  • maxRowLength: the max character a csv row could have. 0 means infinite. If max number exceeded, parser will emit "error" of "row_exceed". if a possibly corrupted csv data provided, give it a number like 65535 so the parser won't consume memory. default: 0

  • checkColumn: whether check column number of a row is the same as headers. If column number mismatched headers number, an error of "mismatched_column" will be emitted.. default: false

  • eol: End of line character. If omitted, parser will attempt to retrieve it from the first chunks of CSV data.

  • escape: escape character used in quoted column. Default is double quote (") according to RFC4108. Change to back slash (\) or other chars for your own case.

  • includeColumns: This parameter instructs the parser to include only those columns as specified by the regular expression. Example: /(name|age)/ will parse and include columns whose header contains "name" or "age"

  • ignoreColumns: This parameter instructs the parser to ignore columns as specified by the regular expression. Example: /(name|age)/ will ignore columns whose header contains "name" or "age"

  • alwaysSplitAtEOL: Always interpret each line (as defined by eol like \n) as a row. This will prevent eol characters from being used within a row (even inside a quoted field). Default is false. Change to true if you are confident no inline line breaks (like line break in a cell which has multi line text).

  • nullObject: How to parse if a csv cell contains "null". Default false will keep "null" as string. Change to true if a null object is needed.

  • downstreamFormat: Option to set what JSON array format is needed by downstream. "line" is also called ndjson format. This format will write lines of JSON (without square brackets and commas) to downstream. "array" will write complete JSON array string to downstream (suitable for file writable stream etc). Default "line"

  • needEmitAll: Parser will build JSON result is .then is called (or await is used). If this is not desired, set this to false. Default is true. All parameters can be used in Command Line tool.

PreviousFW.getBitNextFW.machineLearningPredict

Last updated 1 year ago

Was this helpful?

noheader:Indicating csv data has no header row and first row is data row. Default is false. See

headers: An array to specify the headers of CSV data. If --noheader is false, this value will override CSV header row. Default: null. Example: ["my field","name"]. See

colParser: Allows override parsing logic for a specific column. It accepts a JSON object with fields like: headName: <String | Function | ColParser> . e.g. {field1:'number'} will use built-in number parser to convert value of the field1 column to number. For more information See

More information here:

👩‍🎓
header row
header row
details below
https://github.com/Keyang/node-csvtojson#parameters