Good new about Scala is, actually not only about Scala but all other JVM based languages is that they can take advantages of Java libraries. Since the Scala is a JVM based programming language its easy to use Java libraries and classes with it.
I needed to parse complex CSV file with Scala and create MongoDB object to represent an each row of the CSV file. This would have been easy if I was asked to create MongoDB objects using a JSON file because the JSON is highly supported by the MongoDB. But here I only got complex CSV file with loads of data. First I found some good tutorial about Scala CSV parsing and started my work.
Yes I'm using Play framework 2.0.2 with Scala and MongoDB. I found opencsv is the best solution for parsing CSV files with Scala. Opencsv is for Java but as we already know that Scala is a JVM based language we can go with it.
First I updated my build configuration file to reflect the application dependencies for opencsv.
add this dependencies to your config file.
I needed to parse complex CSV file with Scala and create MongoDB object to represent an each row of the CSV file. This would have been easy if I was asked to create MongoDB objects using a JSON file because the JSON is highly supported by the MongoDB. But here I only got complex CSV file with loads of data. First I found some good tutorial about Scala CSV parsing and started my work.
Yes I'm using Play framework 2.0.2 with Scala and MongoDB. I found opencsv is the best solution for parsing CSV files with Scala. Opencsv is for Java but as we already know that Scala is a JVM based language we can go with it.
First I updated my build configuration file to reflect the application dependencies for opencsv.
add this dependencies to your config file.
"net.sf.opencsv" % "opencsv" % "2.1"This will download the dependent jar files to your repository. You should close eclipse and compile the project and you can see that dependencies are downloaded.
Comments