Giter Site home page Giter Site logo

First column cannot be populated about gocsv HOT 6 CLOSED

zhezack avatar zhezack commented on July 20, 2024
First column cannot be populated

from gocsv.

Comments (6)

SirRamEsq avatar SirRamEsq commented on July 20, 2024 19

I had a similar issue. For those who may be struggling, here was my situation/solution

I had exported a .csv file from MS Excel. I exported it out in UTF-8 format (or, so I thought). The file looked fine in Notepad++ at first glance, but gocsv would not find the first column.
Upon opening the .csv in Notepad++ and looking at the Encoding, I saw that it was not UTF-8, but UTF-8-BOM
Changing the Encoding to UTF-8 and saving the file allowed me to get the first column of .csv using gocsv

from gocsv.

pikanezi avatar pikanezi commented on July 20, 2024

Hello,

I just tried with this sample:

b := bytes.NewBufferString(`number,column_a,column_b
1,a,b
2,c,d
3,e,f`)
	var samples []Whatever
	if err := Unmarshal(b, &samples); err != nil {
		t.Fatal(err)
	}
	log.Println(samples)

and it prints [{1 a b} {2 c d} {3 e f}].

What method did you used?

from gocsv.

zhezack avatar zhezack commented on July 20, 2024

i read from file. If i read from string work correctly

os.OpenFile("sample.csv", os.O_RDWR, os.ModePerm)

from gocsv.

zhezack avatar zhezack commented on July 20, 2024

solved my csv file was wrong i dont know why.
thanks

from gocsv.

bfitzsimmons avatar bfitzsimmons commented on July 20, 2024

@SirRamEsq I had this exact same issue. Thank you for sharing your solution!

from gocsv.

dewey avatar dewey commented on July 20, 2024

Yep, it's the invisible BOM characters at the beginning of the file. I wrote this up in more detail here because I had the same problem with this library.

from gocsv.

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.