Skip to content

Commit 510c08c

Browse files
committed
nan on empty string
1 parent bbbc523 commit 510c08c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Waterfall chart preset not aligned.
99
- Split chart count negative values too.
1010
- Split chart handled when same dimension on main and sub axis.
11+
- Add record didn't handle when a measure got an empty string.
1112

1213
### Changed
1314

src/dataframe/impl/dataframe.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ void dataframe::add_record(std::span<const char *const> values) &
393393
auto &s = *unsafe_get<source_type::owning>(source);
394394
s.normalize_sizes();
395395

396-
std::vector<double> measures(s.measure_names.size());
396+
std::vector measures(s.measure_names.size(),
397+
std::numeric_limits<double>::quiet_NaN());
397398
std::vector<std::string_view> dimensions(
398399
s.dimension_names.size());
399400
for (const auto *it = values.data(); const auto &col : *vec) {
@@ -407,8 +408,10 @@ void dataframe::add_record(std::span<const char *const> values) &
407408
break;
408409
case measure:
409410
char *eof{};
410-
measures[&unsafe_get<measure>(ser).second
411-
- s.measures.data()] = std::strtod(*it, &eof);
411+
if (**it != '\0')
412+
measures[&unsafe_get<measure>(ser).second
413+
- s.measures.data()] =
414+
std::strtod(*it, &eof);
412415
if (eof == *it) error(error_type::nan, *it);
413416
break;
414417
}

0 commit comments

Comments
 (0)