Excuse me if this is a silly question, I'm a complete Groovy noob and I'm tearing my hair out.
Trying to run an example groovy script:
@Grab('com.xlson.groovycsv:groovycsv:1.0')
import static com.xlson.groovycsv.CsvParser.parseCsv
def csv = '''Name:Lastname
Mark:Andersson
Pete:Hansen'''
def data = parseCsv(csv, autoDetect:true)
for(line in data) {
println "$line.Name $line.Lastname"
}
And getting the following error:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, /home/kmcghee/groovy/dev/import_csv/test: 2: unexpected token: import @ line 2, column 1.
import static com.xlson.groovycsv.CsvParser.parseCsv
I've googled a lot on this and it appears to be related to Grapes but I can't pin down the issue. Any ideas?
Best Solution
Thanks for the comments. After noting the versions you guys are using I updated to the latest and it now works. 'apt-get install' gave me 1.8 and I hadn't checked. Schoolboy.