Processing learning from unformatted data using RegEx Someti

Processing (learning from) unformatted data using RegEx

Sometimes this is done for nefarious purposes; mining the internet for email addresses to be used in spamming, or worse. But it has many useful purposes. Text that represents ‘data,’ but not easily accessible ‘information.’ Getting information from data that isn’t in an accessible database format is a valuable skill.

In this exercise you will read a text file called ValenciaCourses.txt, and process each line with a RegEx.   

Write into an output file the courses that have a lab component that is more than 3 hours.    Here is an example of a class that has 2 credit hours, no classroom hours, and 6 lab hours:

CVT 1840L 2 0 6

Your file will include all of the courses with more than 3 lab hours, and a count of the number of classes that have more than 3 hours of Lab.

Post the courses that you found, and the number of them (not your code).

Include the courses and the number of courses that you found in your assignment submission.

This assignment is a Java programming excersice on RegEx using eclipse. The assignement details are below. The professor gave us a link (though it\'s restricted to only students) to the full text of courses but it\'s too large to input into eclipse by hand so I\'m not sure how to input it to look for the patterns.

A snippet of the given valencia courses are:

Solution

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Chegg_27_2_2017 {

   public static void main(String[] args) throws IOException {

       try (Scanner sc = new Scanner(new File(\"ValenciaCourses.txt\"));
               BufferedWriter out = new BufferedWriter(new FileWriter(\"OutputFile.txt\"));) {
           int courseCount = 0;
           while (sc.hasNextLine()) {
               String aLine = sc.nextLine();
               if (aLine.matches(\".+\\\\s.+\\\\s\\\\d{1,2}\\\\s\\\\d{1,2}\")) {
                   String[] lineSplit = aLine.split(\" \");
                   // not clear in question whether >= 3hourse or > 3hours
                   if (Integer.parseInt(lineSplit[lineSplit.length - 1]) > 3) {
                       out.write(aLine + \"\ \");
                       courseCount++;
                   }
               }
           }
           out.write(\"---------------------------------------------------------------\ \");
           out.write(\"No of courses that have a lab component that is more than 3 hours = \" + courseCount + \"\ \");
       } catch (Exception e) {
           System.out.println(e.getMessage());
       }
   }

}

Processing (learning from) unformatted data using RegEx Sometimes this is done for nefarious purposes; mining the internet for email addresses to be used in spa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site