-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (42 loc) · 1011 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"fmt"
"os"
)
//Ideas
//sorting -- checking types
//highlight full line across columns possible???
//don't like column sizing idea. not sure fixable
type csvView struct {
fields_n int
records_len int
has_header bool
header []string
records [][]string //actual data
max_widths []int //actual widths
width_ratios []float64 //testing column sizing calculations
}
var mv csvView
func main() {
filePath := ""
var has_header = flag.Bool("nh", false, "the csv file does not have a header listing field names.")
flag.Parse()
if len(os.Args) > 1 {
//TODO better way to do this may lie in flag
filePath = os.Args[len(os.Args)-1] //assume file comes last
} else {
fmt.Println("Usage:", os.Args[0], "FLAGS <csv file>")
flag.PrintDefaults()
os.Exit(-1)
}
mv.has_header = !*has_header
f := open_csv_file(filePath)
err := read_file(&mv, f)
if err != nil {
fmt.Println("Error", err)
os.Exit(-1)
}
f.Close()
run_ui()
}