Skip to content

Commit 7d94f9c

Browse files
Merge pull request #18 from elsevierlabs-os/ISSUE-15
Ensure that values end up in the correct column for SPARQL results
2 parents bf18548 + aa677cf commit 7d94f9c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/extension.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -954,14 +954,22 @@ export function activate(context: vscode.ExtensionContext) {
954954
var data = [];
955955

956956
if (result.length > 0) {
957-
for(let r of result){
958-
let stringresult = [];
959-
for(let v of r.keys()){ // variables are key in the map
960-
957+
// First populate the list of variables, otherwise we might miss some.
958+
for(let r of result) {
959+
for(let v of r.keys()) {
961960
if (!variables.includes(v)) {
962961
variables.push(v);
963962
}
964-
if (r.get(v).value != undefined) {
963+
}
964+
}
965+
966+
for(let r of result){
967+
console.log(JSON.stringify(r))
968+
let stringresult = [];
969+
for(let v of variables){ // variables are key in the map, we hope.
970+
971+
972+
if (r.get(v) != undefined && r.get(v).value != undefined) {
965973
stringresult.push(r.get(v).value);
966974
} else {
967975
stringresult.push("");
@@ -970,7 +978,6 @@ export function activate(context: vscode.ExtensionContext) {
970978
}
971979
data.push(stringresult);
972980
}
973-
974981
}
975982

976983
// Build a CSV file

0 commit comments

Comments
 (0)