O'Reilly logo

Automate it! - Recipes to upskill your business by Chetan Giridhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Developing your own CSV dialects

To make it easier to read and write into CSV files, we can specify the formatting parameters that are a part of the Dialect class of the csv module. Here, we look at some of the dialects available and learn how to write our own.

Getting ready

For this recipe, we will use the same csv module that is present in the default installation of Python, so there is no need to install anything explicitly.

How to do it...

  1. Let's first look at some of the attributes that are present in the Dialect class:
    • Dialect.delimeter: We used this in the previous recipe where we changed the way the contents are written in the row of a CSV file. It is used to separate two fields.
    • Dialect.lineterminator: This is used to signify the termination ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required