diff options
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) |