From 7ec88e1310e575713fec4f797e03e96d48545be1 Mon Sep 17 00:00:00 2001 From: Patrick Troy Date: Fri, 28 Jun 2024 08:30:07 +0100 Subject: [PATCH] replace np.nan with blank --- liiatools/common/stream_filters.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/liiatools/common/stream_filters.py b/liiatools/common/stream_filters.py index 5b3b79e4..580d4258 100644 --- a/liiatools/common/stream_filters.py +++ b/liiatools/common/stream_filters.py @@ -2,6 +2,7 @@ import xmlschema import tablib import pandas as pd +import numpy as np import xml.etree.ElementTree as ET from io import BytesIO, StringIO from typing import Iterable, Union, Any, Dict, List @@ -105,6 +106,9 @@ def _pandas_dataframe_to_stream(dataset: pd.DataFrame, **kwargs): for r_ix, row in enumerate(dataset.itertuples(index=False)): yield events.StartRow() for c_ix, cell in enumerate(row[0:]): + if isinstance(cell, float): + if np.isnan(cell): + cell = "" yield events.Cell( r_ix=r_ix, c_ix=c_ix,