0

I'm trying to see how to reference column names when using alasql from the command line, when there's no header in the file?

I've tried a few different options with no luck.

e.g

$ alasql 'SELECT a[1] FROM TAB(?) as a' data.csv
$ alasql 'SELECT [1] FROM TAB(?) as a' data.csv

but they all give me an empty result set, like so:

[
  {},
  {},
  {}
]
Brad Parks
  • 66,836
  • 64
  • 257
  • 336

1 Answers1

0

I couldn't see how to do it with implied column names, so I just ended up adding a header to my csv files, and writing the code in javascript. It worked fine from there.

var alasql = require("alasql");

alasql.promise('SELECT * FROM TAB("../data/table1.tab", {headers:true}) a, TAB("../data/target_tags.tab", {headers:true}) b WHERE a.tag = b.tag')
.then(function(data){
  if (data.length > 0)
  {
    console.log("Some bad tags still exist!");
    console.log(data);
  }
  else
  {
    console.log("All bad tags have been removed!");
  }
}).catch(function(err){
     console.log('Error:', err);
});
Brad Parks
  • 66,836
  • 64
  • 257
  • 336