aboutsummaryrefslogtreecommitdiff
path: root/src/ee/ds
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-07-29 12:02:46 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-07-29 12:02:46 +0200
commit4dfe4314efc0a4137899f7a0fce7b653a34219ca (patch)
treeb89bb221d949e3ea06432376b714d24d82b25634 /src/ee/ds
parentde9e6739543fd6a589b80184e5452a6a5cdb1196 (diff)
downloadee-python-4dfe4314efc0a4137899f7a0fce7b653a34219ca.tar.gz
ee-python-4dfe4314efc0a4137899f7a0fce7b653a34219ca.tar.bz2
ee-python-4dfe4314efc0a4137899f7a0fce7b653a34219ca.tar.xz
ee-python-4dfe4314efc0a4137899f7a0fce7b653a34219ca.zip
o Starting on a digikey-specific order csv.
o Better demo, one generic order csv and two for digikey with different batch sizes.
Diffstat (limited to 'src/ee/ds')
-rw-r--r--src/ee/ds/__init__.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ee/ds/__init__.py b/src/ee/ds/__init__.py
index 030113b..f71a7c6 100644
--- a/src/ee/ds/__init__.py
+++ b/src/ee/ds/__init__.py
@@ -347,7 +347,8 @@ class DataSetManager(object):
# noinspection PyMethodMayBeStatic
def store_csv(self, path: Union[str, Path], ds: DataSet, object_type: str,
- order_by: Union[str, Iterable[str]] = None):
+ order_by: Union[str, Iterable[str]] = None, fields: List[str] = None,
+ include_extra_fields: bool = True):
items = [o for o in ds.items() if o.object_type.name == object_type]
if order_by:
@@ -359,10 +360,17 @@ class DataSetManager(object):
raise Exception("Unsupported order_by")
with open(path, "w") as f:
- w = csv.writer(f)
+ w = csv.writer(f, lineterminator=os.linesep)
if len(items):
- header = ds.get_object_type(object_type).fields
+
+ if fields is not None:
+ header = list(fields)
+
+ if include_extra_fields:
+ header.append(set(ds.get_object_type(object_type).fields) - set(header))
+ else:
+ header = ds.get_object_type(object_type).fields
w.writerow(header)
for o in items: