23 lines
624 B
Python
23 lines
624 B
Python
import csv
|
|
from pathlib import Path
|
|
|
|
from tests.factories import B4wExportFactory
|
|
|
|
NUMBER_OF_ROWS = 50
|
|
DEFAULT_PATH = Path("tests/test_data/b4w_export_dummy_01.csv")
|
|
|
|
|
|
def save_csv(path: Path = DEFAULT_PATH):
|
|
data = B4wExportFactory.batch(NUMBER_OF_ROWS)
|
|
row_fields = list(data[0].parameters_to_dict())
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
with path.open("w", newline="") as fid:
|
|
writer = csv.DictWriter(fid, fieldnames=row_fields)
|
|
writer.writeheader()
|
|
for export in data:
|
|
writer.writerow(export.parameters_to_dict())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
save_csv()
|