From f6bfe36b20a9f8ea521421ca750d75ef94590920 Mon Sep 17 00:00:00 2001 From: David Megginson Date: Mon, 20 Oct 2014 14:03:12 -0400 Subject: [PATCH] Fix normalized values. --- scripts/import-data.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/import-data.php b/scripts/import-data.php index 0c335b6..899fee9 100644 --- a/scripts/import-data.php +++ b/scripts/import-data.php @@ -36,7 +36,8 @@ $n = 0; $hxl = new HXLReader(STDIN); $first_row = true; -$col_ids = []; +$col_ids = array(); +$tags = array(); // Process each row foreach ($hxl as $row) { @@ -48,14 +49,24 @@ foreach ($row as $i => $value) { if ($first_row) { // If it's the first row, we need to create each column as we go (and save for future use) + $tag = get_tag($value->column->hxlTag); if (!get_tag($value->column->hxlTag)) { printf("Adding previously-unknown HXL tag %s\n", $value->column->hxlTag); add_tag($value->column->hxlTag, $value->column->headerText, 'Text'); + $tag = get_tag($value->column->hxlTag); } + array_push($tags, $tag); array_push($col_ids, add_col($import_id, $value->column->hxlTag, $value->column->headerText)); } // add the actual value - add_value($row_id, $col_ids[$i], $value->content, $value->content); + + if ($tags[$i]->datatype == 'Number') { + $norm = 0 + $value->content; + } else { + $norm = strtolower(trim(preg_replace('/\s+/', ' ', $value->content))); + } + + add_value($row_id, $col_ids[$i], $value->content, $norm); } // Past the first row $first_row = false;