Code Monkey home page Code Monkey logo

java-sensor-data-from-csv-v2's Introduction

Java program for parsing data from CSV and creating new CSVs version 2.0

This is a project I had in university in the third year at the Java and Python Programming course. This course was taught by Conf. Dr. Ing. Victor Constantin.
I had to find a way to parse a comma separated values (CSV) file which had some data from sensors, the CSV had three different columns for temperatures, three different columns for humidity, one for velocity, two columns for presence (it was a Boolean value), one row for time for that particular value and one for current number.
The task was to create a different CSV for each type of values form the sensors (e.g., one CSV for all three columns of temperatures). Every CSV needed to have a column (beside the values) for the date when the readings were done and also a column for the current number.
There were some restrictions for each new CSV:

  • Temperature: there I had to overwrite the value to be between -5 and 5 and set it to -5 if it was lower than -5 and 5 if it was higher than 5.
  • Humidity: there I had to overwrite the values form the sensor to be 40 if they are lower than 40
  • Velocity: there I had to increment the value from the sensor with 1

My solution

This is my second solution for the project. This solution is more OOP based and each line is commented (being my final solution). Here I used System.getProperty(“user.dir”) to avoid hardcoding the path, that line is for the current directory of the java project.
I created only one class with two private methods first is enrange(Double value, Double min, Double max), this method is used to delete verify the data for the overwriting and the second one is getValue(String[] row, int index) this method is checking for the column for each type of value form the sensor and return the first private method. This class also have a method GenerateCSV(String in, String out, int… columns) for generating the CSV :>, for that I used a for loop for every line in the CSV and then a foreach loop where for the values I called the getValue() function.

java-sensor-data-from-csv-v2's People

Contributors

brittleru avatar

Stargazers

Ana-Maria Luisa Mocanu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.