Comments (6)
Closing the reader does produce an error and stop the marshalling process. My problem was with my surrounding code, forgetting to close the channel. Only if the marshalling completes successfully is the channel closed.
from gocsv.
Are you using https://godoc.org/github.com/gocarina/gocsv#UnmarshalToChan ?
from gocsv.
Yes I am using this method.
I have a few downstream consumers that need the input channel to be closed
before they can exit.
On 2 Mar 2016 3:59 p.m., "Vincent Nรซel" [email protected] wrote:
Are you using https://godoc.org/github.com/gocarina/gocsv#UnmarshalToChan
?โ
Reply to this email directly or view it on GitHub
#24 (comment).
from gocsv.
I don't see any clean way to do that. You could close the channel, but it would panic because you can't send values to a closed channel.
I don't know of any easy method to check if a channel is closed without trying to read from it.
If you have an idea to how we could do that without changing the API, i would be happy to hear it. If not, the only solution would be to write another function which take two channels, one which will be the output of the csv read and the other one to cancel the unmarshalling.
from gocsv.
Is there any way to detect that the reader is close and nothing left to read?
If not then I would agree adding a cancelation channel would be to natural route forward.
Would you accept a pull request adding this functionality using this approach?
from gocsv.
Yes of course :) I will look into why does closing the reader does not stop the reading, looks suspicious to me.
from gocsv.
Related Issues (20)
- [BUG] Fails if comma is present in a header name HOT 4
- UnmarshalToCallback leak goroutine HOT 2
- Race condition if multiple threads are parsing CSV and somebody calls SetHeaderNormalizer
- Custom convertes of data types that are not in the project scope
- Custom Parent.Child Combine String
- `getCSVFieldPosition` works wrong if column name contains zero width characters HOT 1
- 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
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.