Commit ff55b33a authored by Romain Loth's avatar Romain Loth

csv reldb entries: allow specifying the delimiter

parent 9603a31f
......@@ -87,10 +87,12 @@ Expected type is `"csv"` and you should fill the columns to search in and the te
"csv" : {
"file": "$$relpath/to/some.csv",
"qcols": ["list", "of", "cols", "to", "search", "in", "for", "node0"],
"delim": ";"
"template": "bib_details"
}
}
```
NB: the delim parameter is optional (tab is used by default)
###### => for a cortext sql base
Expected type is `"CortextDB"` and you should fill the tables to search in.
......
......@@ -82,7 +82,19 @@
}
}
},
"test_with_various_atts.gexf": {}
"ProgrammeDesCandidats.gexf": {
"node0": {
"name": "term",
"reldbs": {
"csv": {
"file": "ProgrammesCandidats2017.csv",
"delim": ",",
"qcols": ["title","abstract","node0"],
"template": "bib_details"
}
}
}
}
}
},
"data/politoscope": {
......
......@@ -22,6 +22,7 @@ if ($dbtype == "CortextDB") {
else {
// to index: the union of "searchable columns" qcols for all nodetypes
$idxcolsbytype = [];
$altcsvsep = $csvsep;
for ($i = 0; $i < $ntypes ; $i++) {
// if nodetype is active
......@@ -36,6 +37,15 @@ else {
the CSV or DB table to query for related documents
(on nodetypeId ".$i.")</p>");
}
// optional conf items: separator
// FIXME: since conf is defined by node type,
// only the last separator will be taken into account
// but allowing two different separators contradicts
// the 1-base-per-graph structure in csv_indexation
if (array_key_exists('delim', $my_conf["node".$i][$dbtype])) {
$altcsvsep = $my_conf["node".$i][$dbtype]['delim'];
}
}
}
......@@ -69,12 +79,12 @@ else {
// echodump("filename CSV", $mainpath.$graphdb);
$csv_search_base = parse_and_index_csv($mainpath.$graphdb,
$idxcolsbytype,
$csvsep, $csvquote);
$altcsvsep, $csvquote);
// -------------------------------------------------------------------------------
if(class_exists('Memcached')){
// **store** in cache for 1/2h
$mcd->set(mem_entry_name($graphdb), json_encode($csv_search_base), 1800);
// **store** in cache for 2 min
$mcd->set(mem_entry_name($graphdb), json_encode($csv_search_base), 120);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment