title: Grails: save parsed csv data to database
body: <p>I have successfully parsed by csv using grails plugin. Now the output looks like:</p>
  
  <p>This is how i parsed the csvFile. I need to save this csv contents to database.How can i do this? </p>
  
  <pre><code>def upload = {
      def f = request.getFile('filecsv')
      if (f.empty) {
          flash.message = 'file cannot be empty'
          render(view: 'uploadForm')
          return
      } else {
  
          def file = request.getFile('filecsv')
          def singlerow = file.inputStream.toCsvReader(['charset': 'UTF-8', 'separatorChar': '|']).eachLine{
              line -&gt;
                  println "The data are"+line
  
  
          }
      }
  }
  </code></pre>
  
  <h3>Output looks like</h3>
  
  <pre><code>The data are[test, 2017-08-21, , , 2017-08-21, 100, 8668a73e55e0824c130337d49f0fc746, , Annual, , , , , , , , , , , , , , , , , , , , , test, 1111, test, test, 1901-03-13, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , asd/asd/sad/incentive/20170906/09062017.csv, 2017-09-06, , 4.7, 30430001]
  The data are[test, 2017-10-07, , , 2017-08-07, 100, asdasdasdasd, , An, , , , , , , , , , , , , , , , , , , , , test, 1111, test, test, 1900-02-15, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , stat/test/test/incentive/20170906/ 09072017.csv, 2017-09-06, , 4.7, 30430001]
  </code></pre>
  
  <p>My domain class:</p>
  
  <pre><code>class Data {
  
  String data1
  Date data12
  Date data13
  Date data14
  Date data15
  String data16
  String data17
  String data18
  String data19
  String data110
  String data111
  String data112
  String data113
  String data114
  String data115
  String data115
  String data116
  String data117
  String data118
  String data119
  String data120
  _____________
  __________
  ___________
  </code></pre>
  
  <p>}
  How can i save this to database of this domain class.</p>