elasticio / csv-component

CSV Reading and Writing component for elastic.io platform
Apache License 2.0
3 stars 7 forks source link

Add Redesigned Action: Read #95

Closed jhorbulyk closed 3 years ago

jhorbulyk commented 3 years ago

Config Fields

Input Metadata

Output Metadata

Implementation Notes

A3a3e1 commented 3 years ago
  1. 1st step - Investigate Read and Write actions rework. 1.1. Check whether https://www.papaparse.com/ lib satisfies the requirements
if0s commented 3 years ago

Hi @jhorbulyk, during development new Read action there were several questions:

  1. By default, after parsing all value is strings, we can use dynamicTyping to try convert them to appropriate data type, but functionality of this method is not really big, for example numbers with space "1 234.5" or comma "1,234" will not be set to number type, only with dot - "1.234" or simple "1234", what we should do:

    • stay all values as strings
    • enable dynamicTyping to let papaparse decide which kind of data to use
    • add dynamicTyping to Config Fields
    • something else...
  2. If header set to false this library create array of string instead of objects, something like this, ['asd', 'fgh', 'jkl']

    • should we convert it to object? It may be like this:
      {
      "field1": "asd",
      "field2": "fgh",
      "field3": "jkl"
      }
    • assing all data to one object:
      {
      "data": [
      "asd",
      "fgh",
      "jkl"
      ]
      }
    • set header as always true
    • something else...
jhorbulyk commented 3 years ago
  1. I guess dynamicTyping can be added as another CSV parse mechanism in the input metadata. If people need more complex parsing than what is built-in to papaparse, they can write there own string parsing expression with JSONata.
  2. I would convert the result to an object where the keys are column0, column1, column2, etc. (Either 0-based or 1-based column counting)