1

I am trying to access a CSV file in Scala for validating the data in it. I succeeded in that. Now i want to dump all of that CSV file into a MongoDB database using the mongoimport utility of MongoDB. But I don't know how to execute this command from Scala. So, please can anyone tell me how to execute terminal commands from Scala?

My mongoimport command is as follows:

$ mongoimport -d dbname -c Colname --type csv --file Address.csv --headerline

Plese, suggest me any solution. Thanks in advance.

1
  • Take a look at scala.sys.process. Commented Sep 23, 2013 at 12:15

2 Answers 2

5

It must be something like this:

import scala.sys.process._
val process: Process = Process("echo Hello World").run()
println(process.exitValue())
Sign up to request clarification or add additional context in comments.

1 Comment

Thanx a lot Tatiana i found it very useful. .
1

You can use sys.process standard library. Check the documentation for a complete description.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.