Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions 40-csvql/csvql.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,18 @@ func newTable(path string) (sql.Table, error) {
return nil, errors.Wrapf(err, "could not read headers in %s", path)
}

tableName := strings.TrimSuffix(filepath.Base(path), ".csv")

var schema []*sql.Column
for _, header := range headers {
schema = append(schema, &sql.Column{
Name: header,
Type: sql.Text,
Source: path,
Source: tableName,
})
}

name := strings.TrimSuffix(filepath.Base(path), ".csv")
return &table{name: name, schema: schema, path: path}, nil
return &table{name: tableName, schema: schema, path: path}, nil
}

func (t *table) Name() string { return t.name }
Expand Down