File: to_csv.py

package info (click to toggle)
python-agate 1.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,996 kB
  • sloc: python: 8,512; makefile: 126
file content (20 lines) | stat: -rw-r--r-- 475 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os


def to_csv(self, dir_path, **kwargs):
    """
    Write each table in this set to a separate CSV in a given
    directory.

    See :meth:`.Table.to_csv` for additional details.

    :param dir_path:
        Path to the directory to write the CSV files to.
    """
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)

    for name, table in self.items():
        path = os.path.join(dir_path, '%s.csv' % name)

        table.to_csv(path, **kwargs)