You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
right now, opening a CSV connection is done like so:
funcfoo() {
// Open the CSV file as a database table.db, err:= csvdriver.Conn{
File: "../data/iris.csv",
Comment: '#',
Comma: ',',
}.Open()
iferr!=nil {
log.Fatal(err)
}
deferdb.Close()
// Start a database transaction.tx, err:=db.Begin()
iferr!=nil {
log.Fatal(err)
}
defertx.Commit()
// Define a SQL query that we will execute against the CSV file.query:="SELECT var3, var4, var5 FROM csv WHERE var5 = \"Iris-versicolor\""// etc...
}
this makes a query rather cumbersome to read.
it should be possible to open a CSV connection with an optional Columns []string field:
// Open the CSV file as a database table.db, err:= csvdriver.Conn{
File: "../data/iris.csv",
Comment: '#',
Comma: ',',
Columns: []string{"sepal_length", "sepal_width", "petal_length", "petal_width", "species"},
}.Open()
such that the query reads:
// Define a SQL query that we will execute against the CSV file.query:=`SELECT petal_length, petal_width, species FROM csv WHERE species = "Iris-versicolor"`
Yes, I like that. In fact you could call this "schema" if you like, because we are really interacting as if it were a database. I guess it depends on how we want the user to think about the interaction. If we are thinking in terms of a DB interaction, I think schema makes sense.
From @sbinet on November 16, 2016 9:15
right now, opening a CSV connection is done like so:
this makes a query rather cumbersome to read.
it should be possible to open a CSV connection with an optional
Columns []string
field:such that the query reads:
What do you think @dwhitena ?
Copied from original issue: go-hep/csvutil#2
The text was updated successfully, but these errors were encountered: