Quickstart
Last updated
Last updated
This page gives you all the information you need to get started validating your CSVs with CsvPath. It is super high-level and quick. You will want to go deeper on other pages later. We're going to do a trivial validation of a CSV file. Validating an Excel file would be essentially the same.
If you need help getting started with Python, try Python.org's intros. Starting with a project tool like Poetry or Jupyter Notebooks can also help.
Feel like skipping the Python? Watch these videos 🎥 or try this Python-free CLI example.
The open source CsvPath Framework is available through PyPI as csvpath
. The project is quite active. You should pin the version you use but update it regularly.
We use Poetry for our own development. If you choose Poetry, all you need to do is:
If you prefer Pip, install CsvPath Framework with one of:
Have a look at the Github project for more details. You can read that site in parallel to this one.
The worker class in CsvPath is unsurprisingly called CsvPath
. For simple validation, it is all you need.
The quickest way to bootstrap a CsvPath Framework project is the command line interface (CLI). The CLI is a super simple tool that is great for fast no-code development. To try the CLI, skip over to Your First Validation, The Lazy Way.
To continue with the simplest possible Python, let's do a hello world.
Create a script file and import CsvPath:
Create a test CSV file. Save it as trivial.csv or whatever name you like.
Make a csvpath. Also a trivial one, just to keep it simple.
This path says:
Open trivial.csv
Scan all the lines
Match every one of them
Here's everything:
What does this script do?
Line 1: imports CsvPath so we can use it
Line 3: is our csvpath that we'll use to validate our test file, trivial.csv
Line 6: fast-forwards though the CSV file's lines. We could also step through them one by one, if we wanted to.
Line 8: checks if we consider the file valid. If the file didn't meet expectations our csvpath would have declared the file invalid using the fail()
function.
When you run your script you should see something like:
Hello-world examples are never super impressive on their own. But you are now ready to dig in and see what CsvPath can really do.
Next, try Your First Validation, the Lazy Way. Also check out the How-tos section for more use cases and examples. If you'd like a helping hand, contact us!