CSVLint is a Ruby-based server for validating CSV files. It checks CSV files against standard structures and schemas, providing detailed feedback on any issues detected.
- Structure Validation: Checks for structural issues, such as inconsistent row lengths, incorrect quoting, and malformed line endings.
- Schema Validation: Validates CSV data against schemas (e.g., JSON-based) to ensure data formats, types, and constraints are met.
- Dialect Options: Flexible options for parsing CSV files, such as delimiters, quoting characters, and line terminators.
- Detailed Reporting: Provides error, warning, and informational feedback on validation results.
Make sure you have the following installed on your system:
- Ruby (version 2.6 or higher)
- Bundler (for managing Ruby dependencies)
Clone the repository from GitHub and navigate into the project directory:
git clone https://github.com/theodi/csvlint-api.git
cd csvlint-api
Ensure you have Bundler installed. If not, you can install it with:
gem install bundler
Then install all required Ruby gems:
bundle install
Create an .env
file in the project root (you can start by copying .env.example
):
cp .env.example .env
Set any necessary environment variables in .env
. At minimum, you should define:
PORT
: The port on which the server will run (default:4567
).
To start the CSVLint server locally, use:
ruby csvlint_server.rb
The server will start on the specified port (default 4567
). You can access it at http://localhost:4567
.
To use CSVLint through a web interface, simply open the URL in your browser:
http://localhost:4567
The CSVLint API allows you to programmatically validate CSV files. You can upload a CSV file or provide a URL to a CSV with optional schema and dialect options.
Example POST
Request:
curl -X POST http://localhost:4567/validate \
-F "file=@/path/to/yourfile.csv" \
-F "schema=@/path/to/yourschema.json" \
-F "dialect={\"delimiter\":\",\",\"quoteChar\":\"\\\"\"}"
Response:
The API responds with JSON validation results. Here’s an example response format:
{
"valid": true,
"errors": [],
"warnings": [],
"info_messages": []
}
- Log in to Render and create a new service.
- Link your GitHub repository.
- Choose the Ruby environment and specify
Gemfile
for dependencies. - Set environment variables, including
PORT
. - Click Create Web Service to deploy.
This project is licensed under the MIT License.