Project csvmodels aims to provide a Django-like, declarative framework for working with csv files. Even if you haven’t worked with Django, or you don’t know what a declarative framework is, just keep in mind that csvmodels‘ main purpose is to provide an easy API for parsing and validating csv data.

Similar Projects

Of cource, working with csv files is a very common task. Naturally, there have been written numerous libraries and programs with similar scope. The following list is not by any means exhaustive but lists several important ones. Try them out!

  • Marty Alchin’s Sheets is the main inspiration for csvmodels.
  • Even though technically django-adaptors follows a very different approach, from a user point of view it is very similar to csvmodels. Django-adaptors scope is much wider (supports both xml and csv and allows creation of django model instances from csv files). On the other hand, csvmodels supports data validation and, having a much smaller codebase, is probably easier to extend.
  • tablib is a “format-agnostic tabular dataset library” that supports csv (among many others). Keep it in mind. Clean and elegant code.
  • csvkit is a command-line utility for working with csv files.
  • Pandas is a beast. Using it just for csv files is probably an overkill. But if you need complex data analysis, definitely try it out.

Why one more?

The first and foremost reason for developing a new library is of cource having a personal itch to scratch. In my field (engineering) I work very often with csv files, so I was searching for a framework that would allow me to:

  • write clean and elegant code.
  • write maintainable code.
  • easily validate csv data according to rules that I would specify (max, min values etc).
  • easily expend it according to my needs.

From the packages mentioned in the previous section, Sheets seems to fit very well with the majority of my requirements. Since it is using metaclasses, it allows you to write very clean code. Also it features a small code base (easy to understand and to modify). On the other hand Sheets is more or less a demonstration package. It was written by Marty Alchin as a part of his book Pro Python and, normally, it lacks certain features. Taking under consideration all these facts, I decided to fork it in order to provide more features, more complete documentation and better test coverage.


Marty Alchin’s book Pro Python is trully excellent. I recommended it whole-heartedly to anyone who want to delve deeper into the Python world.

Why not?

I think that the main reason for not wanting to use something like csvmodels would be performance. If you are dealing with huge files adding wrappers, classes and function calls is probably something that you want to avoid.


To be written.

What’s missing?

  • Python 2 support.
  • DecimalColumn
  • CurrencyColumn
  • DateColumn
  • Writer

Project Versions

Table Of Contents

Previous topic

csvmodels – A Django-like declarative framework for csv files.

Next topic


This Page