0

The problem is that i have 2 files : 1st file having 4 columns as in

1,Sanchit,60,80

2nd file having 2 columns as in

1,(1-(x/y))>1

now i want to apply the formula in 2nd file on values 60 and 80 which i will read from 1st file.

I have tried reading the formula column and wish to compute the formula using the mentioned values, but unable to do so.

Any kind of help will be appreciated. thanx

EDIT : There is a java api that helps. I have included that into my project and now works great Evaluating a math expression given in string form Head over to this link for the solutions

Community
  • 1
  • 1
Sanchit Grover
  • 998
  • 1
  • 6
  • 9
  • Well... looks like you need to write a parser for your formula's. You can look at Parboiled2 - https://github.com/sirthias/parboiled2 – sarveshseri Feb 22 '15 at 09:28
  • Could explain more about the need to store the formula in the text file? Can you code the formula in the Scalding program which would be much simpler and more reliable? – Sasha O Feb 22 '15 at 16:03
  • @SashaO: Actually i am trying to replace sql by scalding . In sql the formula was stored in a table column from which i was replacing the values and x and y. Now the data remains same and i am trying to do the same with scalding – Sanchit Grover Feb 22 '15 at 16:09

1 Answers1

0

Strictly speaking, this is not exacly a Scalding question but you can use something like Apache Commons JeXL to execute formulas dynamically. So you would read the formula from the 2nd file, give it first file record object as a context and execute it.

Sasha O
  • 3,710
  • 2
  • 35
  • 45