Comments (6)
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.
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.
i read from file. If i read from string work correctly
os.OpenFile("sample.csv", os.O_RDWR, os.ModePerm)
from gocsv.
solved my csv file was wrong i dont know why.
thanks
from gocsv.
@SirRamEsq I had this exact same issue. Thank you for sharing your solution!
from gocsv.
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)
- Header for nested time.Time field is incorrect HOT 1
- Option to skip rows that fail to unmarshal HOT 2
- Instancing global configuration values HOT 1
- time format mistake in README.md and examples/full/main.go HOT 1
- Custom bool marshall HOT 1
- Custom Separator HOT 2
- UnmarshalToCallback without header
- Does this library support the latest go version? HOT 1
- Does this library support the latest go version?
- Custom converter to add euro sign fails HOT 1
- UnmarshalString cannot parse string from MarshalString
- No MarshalBytesWithoutHeaders method available
- Support []interface{} as json package does
- unmarshalFile how can i skip line that fail HOT 2
- rune parsed as integer
- why I cant have dots (.) in my csv data
- Use of generics to minimize interface{}
- Uninitialized values not being written, the output format isn't a CSV format.
- Cannot correctly marshal field that contains word "partial"
- Implement mapping functions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gocsv.