Giter Site home page Giter Site logo

Comments (6)

pjebs avatar pjebs commented on August 11, 2024

@propersam can you look at this

from dataframe-go.

pjebs avatar pjebs commented on August 11, 2024

@kaviarasankk

After this line: df, err := imports.LoadFromCSV(ctx, bytes.NewReader(content))
Can you check err. If err != nil, then don't proceed.

from dataframe-go.

pjebs avatar pjebs commented on August 11, 2024

This line is also wrong:

var writers io.Writer
jsonErr := exports.ExportToJSON(ctx, writers, df)

writers is nil. It needs to actually be something.

from dataframe-go.

kaviarasankk avatar kaviarasankk commented on August 11, 2024
           `content, err := coreio.ReadFile(parsedDirectory, file.Name())
	if err != nil{
		fmt.Println(err)
		return
	}

	df, err := imports.LoadFromCSV(ctx, bytes.NewReader(content))
	if err != nil{
		fmt.Println(err)
		log.Fatal(err)
	}

	var writers io.Writer
	jsonErr := exports.ExportToJSON(ctx, writers, df)
	if jsonErr != nil{
		fmt.Println("Json export error")
	}`

Tried the above code still the issue persist

from dataframe-go.

pjebs avatar pjebs commented on August 11, 2024

writers is nil. That's why it's panicing.

from dataframe-go.

propersam avatar propersam commented on August 11, 2024

Hi @kaviarasankk you need to implement Writer properly..

update:
when you use the ExportToJSON method..you are expected to pass a pointer containing file location that the result will be written to..and that is why your 'writer' is supposed to be a pointer to an open file. but instead your writer is empty. Hence the error. so io.writer is not properly implemented
..
or you can try this other method i use..if you like..(if it makes sense in your context)

import "os"

// create/open a file using os.OpenFile
file, err := os.OpenFile("result.json", os.O_CREATE|os.O_WRONLY, 0777) // creates the file if it doesn't exist
if err != nil {
    fmt.Println(err)
}
defer file.Close()

// Then pass your 'file' into the ExportToJSON method
if err := exports.ExportToJSON(ctx, file, df); err != nil {
    fmt.Println(err)
}

from dataframe-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.