How do I read a file with the file designer?

Prev Next

Reading a CSV or Excel file into a query usually means looking up a provider's options and getting the delimiter, the header row and the column types right. The file designer in the Luminesce Query Editor does it with you: pick the file, preview what Luminesce reads from it, adjust until it looks right, and the designer writes the SQL. It can even upload the file to Drive for you first.

Prerequisites

  • Access to the Luminesce Query Editor in the LUSID web app, under Data Virtualisation > Query Editor.

  • Permission to use the provider for the file's location and type, such as Drive.Csv, and to read the file itself. See Query Editor permissions reference.

Methods

Method 1: Read a file

  1. Select the file designer on the toolbar. Its tooltip reads Designer to help read file data from locations such as drive.

  2. On Source and type, choose:

    • Location: where the file is, such as Drive. The list holds every location you have permission to read files from.

    • File type: such as Csv, Excel, SqLite, Xml, Parquet or RawText, depending on the location.

    If the file isn't in Drive yet, select Upload file to upload it now. The designer fills in its location, type and path for you.

  3. Select Next. On File location and filters, enter the File path: the full path and name of the file, such as /trades/today.csv.

    To read several files of the same shape at once, enter a folder's path instead and a Folder filter: a regular expression the file names must match. For files inside a zip file, use Zip filter the same way. Select Add File Name to add a column saying which file each row came from.

  4. Select Next. On More config options, select Preview / Refresh to see what Luminesce reads from the file.

  5. If the preview doesn't look right, change the options for the file type (see Method 2), then select Preview / Refresh again.

  6. Select Generate Sql. The designer closes and puts the query into the editor, at the cursor.

Method 2: Adjust how the file is read

The options on More config options depend on the file type:

File type

Options

Csv

Delimiter (\t for tab), Quote, Escape, Skip pre header and Skip post header rows, whether there's a header row, and Infer type row count: how many rows Luminesce looks at to decide each column's type

Excel

Worksheet (name or number; the first by default), Range or table to read only part of it, and Password for a protected workbook

SqLite

Table: the table in the file to read

Xml

Node path: the elements that become rows, and any Namespaces they use

To rename columns or change their types, select Modify columns after you've previewed the file. For every option a provider supports, see its page, for example Drive.Csv or Drive.Excel.

Method 3: Load the file into LUSID

On More config options, after you've previewed the file, select Writer Designer to write its rows with a writer provider, such as Lusid.Portfolio.Txn.Writer for a file of transactions. The designer adds both the read and the write to your query. See How do I write query results to LUSID with the writer designer?

A write changes real data when you run it, so check the generated query first.

Method 4: Change a file read you've already written

Highlight a use Drive.Csv … enduse block, or one for another file provider, then select the file designer. It opens with that block's settings filled in. When you select Generate Sql, the new block replaces the lines you highlighted.

Troubleshooting

The preview shows everything in one column

The Delimiter is wrong. Set it to the character that separates the values, such as ; or \t for tab, and preview again.

The column names are a row of data, or the first row is missing

Check whether the file has a header row, and set the option for no header row to match. Use Skip pre header to skip title rows above the header.

Upload file is greyed out

You can only upload to Drive. Choose Drive as the Location.

Modify columns or Writer Designer is greyed out

Select Preview / Refresh first.