Join us at Snowflake Summit June 26-29 in Las Vegas!

Several Enhancements Around Loading CSV and JSON Data

Stefan Pabst

02 June 2021

less than a minute read

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.

Related Posts

Get Early Access

Join our community, keep up to date with the latest developments in our monthly newsletter, and get early access to RelationalAI.