File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ func NewCompiler(filepath string) (*Compiler, error) {
4141 }
4242
4343 tableContext := map [string ]* table.Table {
44- "superhero" : & csvTable , // TODO: Remove hardcoded value
44+ table . GetTableNameFromFile ( filepath ) : & csvTable ,
4545 }
4646 return & Compiler {tableContext : tableContext }, nil
4747}
Original file line number Diff line number Diff line change @@ -2,8 +2,18 @@ package table
22
33import (
44 "fmt"
5+ "strings"
56)
67
78func getColumnAlias (index uint ) string {
89 return fmt .Sprintf ("Col_%d" , index )
910}
11+
12+ func GetTableNameFromFile (filename string ) string {
13+ // TODO: Make this much, much smarter
14+ // - Handle multiple extensions: data.txt.csv > data
15+ // - Handle fully qualified paths: /home/rohit/project/data.csv > data
16+
17+ dotLocation := strings .LastIndex (filename , "." )
18+ return filename [:dotLocation ]
19+ }
You can’t perform that action at this time.
0 commit comments