@prisme.ai/format-collection
v1.0.5
Published
An utilitary function to upload csv files in prisme.ai collections.
Downloads
14
Keywords
Readme
An utility tool dedicated to updated Prisme.ai Collections directly from a CSV file.
This utility can be used as a CLI or Node module.
Install.
npm i @prisme.ai/format-collection
Use
As a module
import { formatCollection } from "@prisme.ai/format-collection";
const result = await formatCollection("./data.csv", { excludeBom: true });
The first parameter represents the file path of the file you want to format (it can be .json or .csv). The second parameter is an object representing all the flags detailed in the CLI README.
As a CLI
Directly in your favorite terminal :
format-collection "/Users/ulysse/Documents/myData.csv" --save "/Users/ulysse/Documents/transformedData.json" --inputSeparator ";" --excludeBom "true"
For more informations about how to use the CLI.
About configuration.
This package is intended to use your env variables to define which API to call and how to identify.
However, as sometimes you cannot change env variables (such as into a javascript function hosted by a third party), we allow you to change the config using setConfig
method.
const {
setConfig,
formatCollection,
} = require("@prisme.ai/format-collection");
setConfig({
SESSION_TOKEN: "r:myPrismeaiSessionToken",
GOOGLE_GEOCODE_API_KEY: "MyGoogleGeocodeAPIKey",
API_CORE_URL: "https://api.prisme.ai",
APP_ID: "gogowego-2016",
});
formatCollection(...);