Skip to content

Latest commit

 

History

History

convert-parsed-csv-to-struct-of-arrays-step

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@shanzhai/convert-parsed-csv-to-struct-of-arrays-step Continuous Integration License FOSSA Status Renovate enabled npm npm type definitions

A Shanzhai step which converts a parsed CSV file to a "struct-of-arrays" format where each column is its own array.

Usage

Use ConvertParsedCsvToStructOfArraysStep to convert a parsed CSV to an object suitable for inclusion in the TypeScript global store. For example, returning the following from a trigger's event handler:

new ConvertParsedCsvToStructOfArraysStep(
  `A description of the operation being performed`,
  `aPrefixForAnyGlobals`,
  new ConstantInput([
    [`TestHeaderA`, `TestHeaderB`, `TestHeaderC`],
    [`Test Value A A`, `125`, `null`],
    [`Test Value A B`, `552`, `false`],
    [`Test Value A C`, `924`, `true`],
  ]),
  new OutputWhichReceivesConvertedCSV()
);

Would write the following to the output:

{
  aPrefixForAnyGlobalsTestHeaderA: [
    `Test Value A A`,
    `Test Value A B`,
    `Test Value A C`,
  ],
  aPrefixForAnyGlobalsTestHeaderB: [
    125,
    552,
    924,
  ],
  aPrefixForAnyGlobalsTestHeaderC: [
    null,
    false,
    true,
  ],
};

If the content of a cell is JSON-serializable, that value will be used. If this is not desirable, quote the value (effectively turning it into a JSON string).

Dependencies

This package has no runtime dependencies.

Peer Dependencies

This package has no runtime peer dependencies (it does not expect any other packages to be installed alongside itself).

License

FOSSA Status