I have a tmp variable whose type is map[string][]string and I want to use LoadMaps feature of gota daraframe. But it only accepts []map[string]interface{}. Now I want to find a way to convert map[string][]string to []map[string]interface{}.
func main() {
input := [][]string{
[]string{"b", "3", "abc", "5.3"},
[]string{"a", "4", "efg", "9.1"},
[]string{"b", "4", "abc", "5.3"},
[]string{"c", "3", "hij", "5.5"},
[]string{"a", "2", "abc", "9.2"},
}
tmp := map[string][]string{}
for _, slice := range input {
if len(slice) <= 1 {
continue
}
//fmt.Println(slice)
tmp[slice[2]] = append(tmp[slice[2]], slice[0:2]...)
fmt.Println(reflect.TypeOf(tmp))
}
df := dataframe.LoadMaps(tmp)
}
you could convert map[string][]string
to map[string]interface{}
, then use append method to []map[string]interface{}