diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-16 15:12:59 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-16 15:12:59 +0300 |
commit | 95772acbd2676873d1b1c7b2c4a4df0a44c01293 (patch) | |
tree | 7272615fb596435978e6d8d2aea4d165ac54b1d1 /vk/utils/tracking/db/reader/csv.py | |
parent | track_status.py: move stuff to the package (diff) | |
download | vk-scripts-95772acbd2676873d1b1c7b2c4a4df0a44c01293.tar.gz vk-scripts-95772acbd2676873d1b1c7b2c4a4df0a44c01293.zip |
add CSV database reader
Diffstat (limited to 'vk/utils/tracking/db/reader/csv.py')
-rw-r--r-- | vk/utils/tracking/db/reader/csv.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/vk/utils/tracking/db/reader/csv.py b/vk/utils/tracking/db/reader/csv.py new file mode 100644 index 0000000..b66e397 --- /dev/null +++ b/vk/utils/tracking/db/reader/csv.py @@ -0,0 +1,22 @@ +# Copyright 2016 Egor Tensin <Egor.Tensin@gmail.com> +# This file is licensed under the terms of the MIT License. +# See LICENSE.txt for details. + +import csv + +from ..record import Record + +class Reader: + def __init__(self, path): + self._fd = open(path) + self._reader = csv.reader(self._fd) + + def __enter__(self): + self._fd.__enter__() + return self + + def __exit__(self, *args): + self._fd.__exit__(*args) + + def __iter__(self): + return map(Record.from_row, self._reader) |