Tuesday 14 March 2017

Need help finding largest value in a column in a JSON file (node.js)

I have an assignment in my computation for geophysicist course that the task is basically finding the largest value in a column of a txt file ( the value is the magnitude of the earthquake, and the file contains all earthquakes from 1990-2000). Then take the latitude and longitude of such earthquake(s) and plot it into a map. The task is quite simple to do in python, but since i am devoting some free time to study webdev i am thinking in making a simple webapp that would do the complete task.

In other words, i would a upload a file into it, and it would automatically appoint the biggest earthquakes into a google map.

But since i am kind of a noob in node.js i am having a hard time taking starting the project, so i am breaking into parts, and i need help with the first part of it.

I am thinking of converting the txt.file with data into a csv file and subsequently converting it into a Json file. But i have absolutely no idea what algorithm i should use to scan the json file and find the largest value of a given column.

Here is the first row of the original txt.file:

1 5 0 7.0 274 102.000 -3.000

here it is on a csv file, using an online converter: 1 5 0 7.0 274 102.000 -3.000"

And here it is on the JSON file, again, using on a online converter: 1\t 5\t 0\t7.0\t274\t102.000\t -3.000".

Basically i need to scan all the rows and find the largest value of the 5th column.

Any help on how i would start writing this code?

Thanks very much.

TLDR version:

Need to find the largest value of the 5th column in a JSON file with multiple rows.



via Renan Sanches

No comments:

Post a Comment