CSV
CSVs are a simple file format that stores data in a human-readable, plain text format. They are widely used for data storage and transfer. Evidence supports connecting to CSV files as a data source, allowing you to query them using SQL.
Add a New CSV Data Source
- Start the Evidence dev server:
npm run dev
or Start Evidence using the VSCode extension. - Navigate to the settings page,
also accessible via the
...
menu in the top right. - Click the New Source button.
- Select CSV as the data source type.
- Enter the configuration options for the connection.
- Click the Test button to confirm the connection is successful.
- Click the Save button to save the connection.
- Your configuration options are saved in two files:
/sources/[source_name]/connections.yaml
: Non-sensitive values, source controlled./sources/[source_name]/connection.options.yaml
: Sensitive values, not source controlled, base-64 encoded.
Then copy any CSV files you want to query into sources/[your_csv_source_name]/
. Your source names and csv files can only contain letters, numbers and underscores eg /my_source/my_csv_2024.csv
How to Query a CSV File
Evidence looks for files with the .csv
extension stored in a sources/[your_csv_source_name]/
folder in the root of your Evidence project. You can query them using this syntax:
select * from your_csv_source_name.csv_file_name
Do not include the .csv
extension in the file name when querying.
Configuration
You can add DuckDB source options that are passed in as arguments to the read_csv()
function.
Ensure there are no spaces in your source options you pass, and to use double quotes when passing strings