Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Fix normalized values.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmegginson committed Oct 20, 2014
1 parent 46583fc commit f6bfe36
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scripts/import-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit f6bfe36

Please sign in to comment.