With the Data Engine library, you can import data from CSV files to the DataEngine table into a queryable collection of objects in your code.
Note: For importing data from a CSV file to DataEngine table, you need to add the CsvHelper NuGet package in your application, apart from the C1.DataEngine.Core and C1.DataEngine.Core.Api NuGet packages.
To connect Data Engine to CSV files, you need to follow the steps given below:
Initialize a new workspace folder relative to the project root directory using the Init method of the Workspace class.
Create a class containing properties that can hold the data corresponding to the fields in the CSV file.
In order to map the property names of a class to the header names of the CSV data, you can create a mapping class as shown.
Read CSV data and transform it into an IEnumerable collection of custom .NET objects using the classes and methods available in the CsvHelper Nuget package as shown:
To connect the DataEngine to the retrieved collection of custom .NET objects, create an instance of the ObjectConnector class and pass the Workspace object and IEnumerable collection initialized above, as parameters to its constructor. Use the ObjectConnector’s GetData method to create a DataEngine table containing the imported data.
Once the connection is established, the queries can be defined and executed to fetch the desired data. Refer to Transform Data topic for more details.