rocketlaunchr / dataframe-go

DataFrames for Go: For statistics, machine-learning, and data manipulation/exploration
Other
1.16k stars 93 forks source link

LoadFromJSON Not Working #56

Closed hamiwa closed 2 years ago

hamiwa commented 3 years ago

files, err := ioutil.ReadFile("device.json") if err != nil { fmt.Println(err) }

var ctx = context.Background()
df2, _ := imports.LoadFromJSON(ctx, strings.NewReader(string(files)))

fmt.Println(df2.Table())
pjebs commented 3 years ago

what does your json file look like?

pjebs commented 3 years ago

what is the error message? You are _ the error message.

hamiwa commented 3 years ago

Hi, Please see JSON file content and error msg below:

JSON

[ { "device":"A", "vendor":"A", "nos":"", "address":"A" }, { "device":"B", "vendor":"B", "nos":"B", "address":"B" } ] error

panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x52a54f]

goroutine 1 [running]: github.com/rocketlaunchr/dataframe-go.(*DataFrame).Table(0x0, 0x0, 0x0, 0x0, 0x0, 0x0) C:/Users/BLADE RUNNER/go/pkg/mod/github.com/rocketlaunchr/dataframe-go@v0.0.0-20210422123815-aaa951b82e1b/dataframe_fmt.go:38 +0x4f main.main() C:/Projects/Go/src/projects/data1.go:19 +0x10f exit status 2

pjebs commented 3 years ago

Currently it only supports jsonl format: https://jsonlines.org/

Let me adjust the code on a few days for your use case.

pjebs commented 3 years ago

In the mean time, remove the outer array and then make each object into a new line (no comma)

hamiwa commented 3 years ago

In the mean time, remove the outer array and then make each object into a new line (no comma)

Thanks, I will attempt using the above method and see how this performs - Appreciate the time taken on this.

pjebs commented 2 years ago

Complete. Now it supports loading from JSON arrays, JSONL arrays and JSONL objects. It is also faster at importing.

hamiwa commented 2 years ago

Excellent! I will do some tests and confirm, appreciated.

On Mon, 25 Oct 2021, 06:08 pj, @.***> wrote:

Complete. Now it supports loading from JSON arrays, JSONL arrays and JSONL objects. It is also faster at importing.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rocketlaunchr/dataframe-go/issues/56#issuecomment-950531771, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACACRBLEJRXMS77ASIXF7O3UITQ3LANCNFSM5BK5XIOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.