diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-07-29 12:02:46 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-07-29 12:02:46 +0200 |
commit | 4dfe4314efc0a4137899f7a0fce7b653a34219ca (patch) | |
tree | b89bb221d949e3ea06432376b714d24d82b25634 /src/ee/ds | |
parent | de9e6739543fd6a589b80184e5452a6a5cdb1196 (diff) | |
download | ee-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__.py | 14 |
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: |