Get Help

Csv@1

Csv@1 reads CSV files from a directory with a minimal SQL subset. Nothing to install.

Connects to

CSV files — one data source covers every file in a directory. For full SQL over CSV data (joins, GROUP BY, ORDER BY, functions) use Csv@2; Csv@1 is the one that can also serve lists of definitions.

Example

Name
MyCsvData
Technology
CSV file
Provider
Csv@1
Connection string
.
Data sources:
- Name: MyCsvData
  Provider: Csv@1
  Technology: Csv
  Connection string: . # this directory (where the project file is)

Connection string

Not a connection string and not a file: a path to a directory where the CSV files are. A relative path is resolved against the directory of the project file. One data source can therefore serve hundreds of CSV files that sit in the directory under test. The same slot is also accepted as Directory or Folder — see Data source properties.

Name
generated CSVs
Technology
CSV file
Provider
Csv@1
Connection string
T:\\MySystemTests\\GeneratedCsvFiles
Data sources:
- Name: generated CSVs
  Provider: Csv@1
  Technology: Csv
  Connection string: "T:\\MySystemTests\\GeneratedCsvFiles"

The file itself is named in the query: SELECT * FROM [2020.csv], SELECT * FROM [2021.csv] and so on.

Settings

Setting Default Meaning
Encoding (also Encoding name, Charset) utf-8 Text encoding of the files, parsed with .NET System.Text.Encoding.GetEncoding — any value from the Name column of the .NET encoding list (“List of encodings” section), e.g. windows-1250, utf-32
Name
MyCsvData
Technology
CSV file
Provider
Csv@1
Connection string
.
Encoding
utf-32
Data sources:
- Name: MyCsvData
  Provider: Csv@1
  Technology: Csv
  Connection string: . # this directory (where the project file is)
  Encoding: 'utf-32' # or windows-1250, ...

This is what the .NET documentation looks like — use the Name column:

Encoding names

Query

A SQL statement, even though no database is involved — CAT needs it to know which file to read, because the connection string names only the directory. Only these clauses are supported:

SQL clause Notes
SELECT Either * or a comma-separated list of column names in square brackets. The columns may be listed in a different order than in the file.
FROM Just the name of a file in the directory given by the connection string. No joins.
WHERE Only [Column name] = 'something'; several conditions joined with AND. No functions, no OR, no brackets — simple filtering on one or more columns.
SELECT  [Last Name], [First name]
FROM    [Data.csv]
WHERE   [First Name] = 'Helena' AND [ID] = 2

Prerequisites

None. The driver ships with CAT. Windows; on Linux it has no extra dependencies and is expected to work, but it has not been tested there.

Serving test and data source definitions

Csv@1 can also serve lists of definitions: a CSV file whose header row carries the property names of a test, data source or query definition, one definition per row; the query’s FROM names the file.

  • Technologies — CSV file and the provider behind it.
  • Csv@2 — full SQL over CSV files, no driver either.
  • Lists — loading test and data source definitions from a provider.