Configure CSV source for Products
This example will guide you through the process of configuring a CSV source for products using Völur SDK.
What are sources?
A source is a way to prepare your data to upload it to the Völur.
Available sources can be found in
volur.sdk.v1alpha2.sources
. For this specific
example we will use
ProductsCSVFileSource
.
Configuring a source
Let us say we have a file products.csv
with the following content:
Product ID | Product Name | Product Description | Is Active | Plant Num |
---|---|---|---|---|
1 | product-id-1 | Some description 1 | True | 1000 |
2 | product-id-2 | Another description | True | 1000 |
3 | product-id-3 | This is a different product | True | 1001 |
4 | product-id-4 | Also a product | True | 1002 |
5 | product-id-5 | This product is no longer used | True | 1002 |
To configure a source for this file, you can build a ProductsCSVFileSource
:
Let's break down the configuration:
path
: the path to the CSV file,product_id_column
: the column containing product IDs (we need to uniquely identify each product available in the CSV file),-
characteristics_columns
: all the columns of the CSV file that contain characteristics of the product. In this case, we have four columns:Product Name
is mapped to theproduct_name
characteristic,Product Description
is mapped to thedescription
characteristic,Is Active
is mapped to theis_active
characteristic.Plant Num
is mapped to theplant_code
characteristic.
Use a source with a Völur SDK client
To use the source with a Völur SDK client, you can use the following code:
That's it! You have successfully configured a CSV source for products using Völur SDK.