Is there is any plugin to parse csv file for grails 3.1.1

60 views
Skip to first unread message

Ajay Shah

unread,
Dec 16, 2016, 12:10:11 PM12/16/16
to Grails Dev Discuss
I just want to parse csv file to retrive information from it and use it to update my database accordingly. Is there is any easy way to do this .If not then plain groovy code will be helpful beacuse i tried alot but i had failed to do so.

Gregory Dickson

unread,
Dec 16, 2016, 12:19:58 PM12/16/16
to grails-de...@googlegroups.com
 compile 'com.xlson.groovycsv:groovycsv:1.1'



On Fri, Dec 16, 2016 11:10 AM, Ajay Shah ajay...@sparkwork.io wrote:
I just want to parse csv file to retrive information from it and use it to update my database accordingly. Is there is any easy way to do this .If not then plain groovy code will be helpful beacuse i tried alot but i had failed to do so.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/fdc10f3d-4b1e-41e9-9d4e-de8ceab6d547%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gregory Dickson

unread,
Dec 16, 2016, 12:21:20 PM12/16/16
to grails-de...@googlegroups.com
some Controller Code: 

import static com.xlson.groovycsv.CsvParser.parseCsv

def uploaddetail(){
        if (request.method == 'POST') {
            def submittedFile = request.getFile('file')
            if (submittedFile.empty) {
                flash.message = 'File is mandatory.'
                response.sendError(500)
            } else {
                if (!(submittedFile.getContentType() == 'application/csv'
                        || submittedFile.getContentType() == 'text/csv')) {
                    flash.message = 'File must have a CSV extension.'
                    response.sendError(500)
                } else {
                    def data = parseCsv(submittedFile.getInputStream().getText()
                        def count = 0
                        for (row in data) {



On Fri, Dec 16, 2016 11:10 AM, Ajay Shah ajay...@sparkwork.io wrote:
I just want to parse csv file to retrive information from it and use it to update my database accordingly. Is there is any easy way to do this .If not then plain groovy code will be helpful beacuse i tried alot but i had failed to do so.

--

Ajay Shah

unread,
Dec 16, 2016, 12:52:32 PM12/16/16
to Grails Dev Discuss
import static com.xlson.groovycsv.CsvParser.parseCsv

I had imported this to my contoller but unable to resolve xlson . It appears red. I had compiled the required dependency as you suggested but unable to import this class?

Ajay Shah

unread,
Dec 17, 2016, 6:41:59 AM12/17/16
to grails-de...@googlegroups.com
thanks it solve my problem after resetting my project

--
You received this message because you are subscribed to a topic in the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grails-dev-discuss/kKLcMzWKvao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grails-dev-discuss+unsub...@googlegroups.com.
To post to this group, send email to grails-dev-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/47ce5189-0f63-4bdf-9097-0e242dee883b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages