equal
deleted
inserted
replaced
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """Functions to help importing CSV data""" |
18 """Functions to help importing CSV data""" |
19 |
19 from __future__ import absolute_import, print_function |
20 from __future__ import absolute_import |
|
21 |
20 |
22 import csv as csvmod |
21 import csv as csvmod |
23 import warnings |
22 import warnings |
24 import os.path as osp |
23 import os.path as osp |
25 |
24 |
62 for urow in ucsvreader(stream, encoding, delimiter, quotechar, |
61 for urow in ucsvreader(stream, encoding, delimiter, quotechar, |
63 skipfirst=skipfirst, skip_empty=skip_empty): |
62 skipfirst=skipfirst, skip_empty=skip_empty): |
64 yield urow |
63 yield urow |
65 if withpb: |
64 if withpb: |
66 pb.update() |
65 pb.update() |
67 print ' %s rows imported' % rowcount |
66 print(' %s rows imported' % rowcount) |
68 |
67 |
69 |
68 |
70 def ucsvreader(stream, encoding='utf-8', delimiter=',', quotechar='"', |
69 def ucsvreader(stream, encoding='utf-8', delimiter=',', quotechar='"', |
71 skipfirst=False, ignore_errors=False, skip_empty=True, |
70 skipfirst=False, ignore_errors=False, skip_empty=True, |
72 separator=None, quote=None): |
71 separator=None, quote=None): |