Several Enhancements Around Loading CSV and JSON Data

Posted June 1, 2021 by Stefan Pabst ‐ 2 min read

Introducing new data loading functionalities.

We are continuously working on improving and enhancing our data loading functionalities. Over the last weeks, several new features have been released.

Loading JSON Data within Rel

Most notably, JSON data can now be loaded into your database within Rel as easy as

def config[:path] = "my_data.json"
def json = load_json[config]

and without the need of using an SDK. For more details, please check out our JSON Import and Export tutorial.

Special Characters in CSV Columns Names

We are happy to announce that we support now spaces and many other non-alphanumeric characters in CSV column names. For instance, the file

abbrev.,state name

loads now into Rel as any other CSV file.

def mydata = load_csv["/path/to/my/data.csv"]
def output = mydata
(DelveTypes.FilePos(19), :abbrev., "AL")
(DelveTypes.FilePos(30), :abbrev., "WY")
(DelveTypes.FilePos(19), :state name, "Alabama")
(DelveTypes.FilePos(30), :state name, "Wyoming")

To access your CSV column in Rel, use the new stdlib functionality relname_string.

def output = mydata[_, (col: relname_string(col, "state name"))]

Index CSV data by Row Number

You can now easily index your CSV data with the row number by applying lined_csv on your loaded CSV data.

def mydata = lined_csv[load_csv["/path/to/my/data.csv"]]
def output = mydata
(1, :abbrev., "AL")
(2, :abbrev., "WY")
(1, :state name, "Alabama")
(2, :state name, "Wyoming")

This replaces the standard FilePos data type with and the data row number of the CSV file.