The csvLinter is a .NET Core Web API project designed to validate CSV files against a specified schema. This tool ensures that CSV files conform to expected formats and data types.
You can add your own datatypes as needed, via the schemas folder in JSON format. This contains a few simple examples.
- Validate CSV files for correct number of columns and specific data types.
- Dynamic schema definitions using a Json to map column names, types and values.
- RFC 4180-compliant CSV parsing (via CsvHelper), so quoted fields containing commas, embedded newlines, and escaped quotes are handled correctly.
- JWT-authenticated API, backed by a local SQLite user store.
- Easy integration into other systems or as a standalone service.
Before you begin, ensure you have the following installed:
- .NET 10 SDK or later
- Visual Studio (optional, but recommended for ease of use)
- Clone the Repository Clone this repository to your local machine using Git:
git clone https://github.com/tomblanchard312/csvLinter.git
cd csvLinter
Restore Dependencies Run the following command to restore all the necessary .NET packages:
dotnet restore csvLinter.Api.csproj
Build the Project Compile the project to check for any errors:
dotnet build csvLinter.Api.csproj
Running the Application To run the API locally, use the following command from the repository root (where csvLinter.Api.csproj is located):
dotnet run --project csvLinter.Api.csproj
By default (dotnet run with no --launch-profile) this uses the http profile from Properties/launchSettings.json, which listens on http://localhost:5289. To run over HTTPS on port 7014 instead, use the https profile:
dotnet run --project csvLinter.Api.csproj --launch-profile https
which listens on https://localhost:7014 (and still on http://localhost:5289).
On startup the app automatically applies any pending Entity Framework Core migrations, creating a local csvLinter.db SQLite file for the user store. You can access the API endpoints using a browser or tools like Postman, or via the Swagger UI at /swagger.
The CSV linting endpoint requires a JWT bearer token. Create an account and obtain a token via the auth endpoints below, then pass the token on subsequent requests.
JWT signing is configured under the Jwt section of appsettings.json:
"Jwt": {
"Issuer": "csvLinter",
"Audience": "csvLinter-clients"
}Jwt:Key (the signing key) is intentionally not committed to appsettings.json. A placeholder development-only key is set in appsettings.Development.json. For any non-development environment, supply Jwt:Key via an environment variable, user-secrets, or a secrets manager, for example:
dotnet user-secrets set "Jwt:Key" "your-own-strong-signing-key"
curl -X POST http://localhost:5289/api/Auth/register \
-H "Content-Type: application/json" \
-d "{\"username\":\"myuser\",\"password\":\"MyStrongP@ssw0rd\"}"
curl -X POST http://localhost:5289/api/Auth/login \
-H "Content-Type: application/json" \
-d "{\"username\":\"myuser\",\"password\":\"MyStrongP@ssw0rd\"}"
This returns a JSON body containing a token and its expiresAtUtc. Use the token as a bearer token on the linting endpoint below.
Endpoint: /api/CsvLint
Method: POST
Auth: Authorization: Bearer <token> (see Authentication)
Query: schemaType (matches a schema file name under schemas/)
Body: multipart/form-data with the file upload (csvFile)
Example using cURL:
curl -X POST "http://localhost:5289/api/CsvLint?schemaType=EmployeeDetails" \
-H "Authorization: Bearer <token>" \
-F "csvFile=@path_to_your_file.csv"
Testing Included in the project are sample CSV files like Sample_Employee_Data_Good.csv with dummy data for testing. Use this file to test the CSV linting capabilities of the API. The samples are named good.csv for those that should not produce an error response and bad[reason].csv for those files that should produce an error response and why.
To run the automated test suite:
dotnet test csvLinter.Api.csproj
Contributing Contributions to the csvLinter are welcome. Please fork the repository and submit pull requests to contribute.
License This project is licensed under the Apache 2.0 License.