Skip to content

LokqlDx‐Loading data

NeilMacMullen edited this page Mar 6, 2025 · 3 revisions

Lokqldx holds data in tables internally. The current collection of tables is called the context.

When you first create or load a workspace, the context will be empty and you'll need to re-execute the relevant commands to populate the context.

Tables can be loaded from a number of sources:

  • 'inline' data using the addtable command
  • external files (csv,excel,json,parquet,text)
  • results of queries
  • Azure ApplicationInsights

inline data

The addtable command can be used to quickly add small tables from inline data.

.addtable sampleData
A  |  B
1  |  2
3  |  4

Loading tables from files

External files can be loaded using the .load path-to-file tablename command. The file format is determined by the extension. If no table-name is specified, the file-name (without the extension) is used to name the table. I.e. the command .load C:\mydata\ages.csv will create a table called ages. By default, the .load command will skip the reload of data if the target table already exists but the -f flag can be used to force a reload if, for example, you want to fetch updated data from the file.

image

Drag-and-drop

Dragging and dropping a file with a recognised format into the query editor will automatically insert a .load <file-path> command into the editor. The command can then be run to load the file.

csv/tsv files

Csv files are a common way to store data and are supported. The csv loader has a number of configurable options which are controlled via the .set command...

.set csv.trimcells off

It's common for csv files to

parquet files

json files

excel files

By default only the first sheet is loaded by the .load command. The loadexcel command cane be used to load all worksheets (one table per worksheet)

text files

Materializing previous results

The results of a previous query can be stored back into the context using the materialize command.

.load dataset.csv

dataset 
| extend Category=case(.....)

.materialize categorised

categorised | count
categorised | summarize count() by Category

ApplicationInsights

see....

Clone this wiki locally