Skip to content

Commit

Permalink
Conditional header parsing support
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jan 10, 2019
1 parent 893b92c commit 1313ac7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/appier_extras/parts/admin/models/base.py
Expand Up @@ -346,6 +346,7 @@ def _csv_import(
callback_header = None,
strict = False,
named = False,
header = True,
delimiter = ",",
quotechar = "\"",
quoting = csv.QUOTE_MINIMAL,
Expand All @@ -364,7 +365,8 @@ def _csv_import(
args, _varargs, kwargs = appier.legacy.getargspec(callback)[:3]
has_header = True if "header" in args or kwargs else False
has_map = True if "map" in args or kwargs else False
header = next(csv_reader)
if header: header = next(csv_reader)
else: header = []
if not is_unicode: header = [value.decode(encoding) for value in header]
if callback_header: callback_header(header)
if named: tuple_t = collections.namedtuple("csv_tuple", header)
Expand Down

0 comments on commit 1313ac7

Please sign in to comment.