Closed fils closed 6 years ago
Is that possible that line 106 is returning an error? Could you please check and let me know how it goes?
About the WriteAll
method, it does exist in the interface. Actually, csv.NewWriter returns a csv.Writer :)
So I updated the code (and pushed it up.. same link) https://github.com/OpenCoreData/ocdGarden/blob/master/frictionlessdata/ocdFricTest1/main.go
I added
err = w.Error()
if err != nil {
log.Fatal(err)
}
in a few places and got nothing. Is that the correct way to look for errors?
Then I found an issue.. I had my struct type wrong. However, how this is affecting the running code is interesting.
At line 13 I had my Leg field in my struct as type "string" when in the schema.json it is "int". running with this mismatch results in no error, and no file.
If I change line 13 to int and run I get the following.
.... (removed some extra output doing simple field printing
2017/10/09 06:57:49 21 - Calib_density_m0
2017/10/09 06:57:49 22 - Calib_density_m1
2017/10/09 06:57:49 23 - Calib_density_mse
2017/10/09 06:57:49 Field Section_number exists in schema
2017/10/09 06:57:49 Unmarshal to value: 123
{208 1262 C 90}
panic: runtime error: index out of range
goroutine 1 [running]:
opencoredata.org/ocdGarden/frictionlessdata/ocdFricTest1/vendor/github.com/frictionlessdata/tableschema-go/schema.(*Schema).Encode(0xc42011e000, 0x1299a80, 0xc42007f9b0, 0xc42007f9b0, 0x0, 0x0, 0x0, 0x0)
/Users/dfils/src/go/src/opencoredata.org/ocdGarden/frictionlessdata/ocdFricTest1/vendor/github.com/frictionlessdata/tableschema-go/schema/schema.go:249 +0x502
main.validateSchema1()
/Users/dfils/src/go/src/opencoredata.org/ocdGarden/frictionlessdata/ocdFricTest1/main.go:109 +0x966
main.main()
/Users/dfils/src/go/src/opencoredata.org/ocdGarden/frictionlessdata/ocdFricTest1/main.go:21 +0x20
exit status 2
Thanks for the note re: WriteAll. Oddly VSCode doesn't show it as an function option (my bad for crutching on my editor and not reading the docs.).
Hi @fils,Thanks for reporting this error. I fixed it on my last commit and just pushed version 0.1.4 with the fix (and some more stuff).
I also noticed that you didn't check the error returned at schema.DecodeTable. Could you please do so? This check is important because we can not guarantee the integrity of the returned value in case of errors.
@danielfireman looks good.. FYI, I think in main README you want the demo code for the WriteSummary function to be
f, _ := os.Create(path)
not os.Open.
Thanks! issue resolved for me!
Thanks for reporting, @fils ! Already fixed the README.
Using your code on the main README as a guide I have lines like in https://github.com/OpenCoreData/ocdGarden/blob/master/frictionlessdata/ocdFricTest1/main.go Lines 95-108
No errors and runs fine, but no file is made. Tried adding in some manual w.Flush() calls but didn't work.
I also tried
but it return error as nil, so nothing to report.
Any guidance on what I am doing wrong?
Also, have you thought of a method like w.WriteAll() like in the golang csv package?