import (
"encoding/json""fmt""github.com/FerdinaKusumah/excel2json""log"
)
funcmain() {
var (
result []*map[string]interface{}
errerrorurl="https://raw.githubusercontent.com/curran/data/gh-pages/senseYourCity/all.csv"// select only selected field// if you want to show all headers just passing nil or empty listheaders= []string{"humidity", "sound"}
delimited=","
)
ifresult, err=excel2json.GetCsvFileUrl(url, delimited, headers); err!=nil {
log.Fatalf(`unable to parse file, error: %s`, err)
}
for_, val:=rangeresult {
result, _:=json.Marshal(val)
fmt.Println(string(result))
}
}
Read csv from local source
import (
"encoding/json""fmt""github.com/FerdinaKusumah/excel2json""log"
)
funcmain() {
var (
result []*map[string]interface{}
errerrorpath="./all.csv"// select only selected field// if you want to show all headers just passing nil or empty listheaders= []string{"humidity", "sound"}
delimited=","
)
ifresult, err=excel2json.GetCsvFilePath(path, delimited, headers); err!=nil {
log.Fatalf(`unable to parse file, error: %s`, err)
}
for_, val:=rangeresult {
result, _:=json.Marshal(val)
fmt.Println(string(result))
}
}
Contributors are welcome !!
About
Excel to json so easily, read from local source or remote source