Results 1 to 5 of 5

Thread: Easy App CSV

  1. #1
    valeboccaccio is offline Member
    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Default Easy App CSV

    Hi guys, thank you in advance for the help that you give me, I'll explain my situation.
    I comed from Android but I'm a newbie in programming in general.
    I am now in contact with Java.
    I have to develop an app that given as input a CSV file with 6 fields such as fact:


    #Keyword, Competitor, Search Engine, Position, Web Page, Changes,
    beer, 27300000, Google Universal Italy, 1, http:/it.wikipedia.org/wiki/Birra, +,
    beer, 27300000, Google Universal Italy, 2, http:/www.birra.it, +,
    beer, 27300000, Google Universal Italy, 3, http:/www.albanesi.it/, +
    ale, 7300000, Google Universal Italy, 1, http:/it.wikipedia.org/wiki/Birra, +,
    ale, 7300000, Google Universal Italy, 2, http:/www.birra.it, +,
    ale, 7300000, Google Universal Italy, 3, http:/www.albanesi.it/, +
    dark beer, 300000, Google Universal Italy, 1, http:/it.wikipedia.org/wiki/Birra, +,
    dark beer, 300000, Google Universal Italy, 2, http:/www.birra.it, +,
    dark beer, 300000, Google Universal Italy, 3, http:/www.albanesi.it/, +
    #

    face a ranking by assigning a score to each domain based on the position in the standings and finally the final classification by the sum of the rankings for each key.

    for example
    Keyword Domination Score
    beer, Wikipedia, 30
    beer, Birra, 20
    beer, Albanesi, 10

    etc. etc.

    final Standings
    Domination Score
    Wikipedia, 90
    Birra, 40
    Albanesi, 30

    The output file must be CSV.
    I hope I was clear enough and thank you again.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    902
    Rep Power
    2

    Default Re: Easy App CSV

    Java Code:
    public class CSV {
        public static void main(String[] args) {
            try {
                BufferedWriter w = new BufferedWriter(new FileWriter("rankings.csv"));
                w.write("Keyword,Domination,Score" + Character.LINE_SEPARATOR);
                w.write("beer, Wikipedia, 30" + Character.LINE_SEPARATOR);
                w.write("beer, Birra, 20" + Character.LINE_SEPARATOR);
                w.write("beer, Albanesi, 10" + Character.LINE_SEPARATOR);
                w.flush();
                w.close();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    If you copy paste this, you can make the second example as well.

  3. #3
    valeboccaccio is offline Member
    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Default Re: Easy App CSV

    Quote Originally Posted by SurfMan View Post
    Java Code:
    public class CSV {
        public static void main(String[] args) {
            try {
                BufferedWriter w = new BufferedWriter(new FileWriter("rankings.csv"));
                w.write("Keyword,Domination,Score" + Character.LINE_SEPARATOR);
                w.write("beer, Wikipedia, 30" + Character.LINE_SEPARATOR);
                w.write("beer, Birra, 20" + Character.LINE_SEPARATOR);
                w.write("beer, Albanesi, 10" + Character.LINE_SEPARATOR);
                w.flush();
                w.close();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    If you copy paste this, you can make the second example as well.
    I'm sorry I did not understand.
    I must read the csv file, assign the scores, do the sums of scores, print a new csv with the ranking.

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    902
    Rep Power
    2

    Default Re: Easy App CSV

    To read files: BufferedReader, FileReader
    To split on commas: String.split, StringTokenizer
    Parse numbers: Integer.parseInt, Double.parseDouble
    To sum: +
    To write files: BufferedWriter, FileWriter

    You will not get your code handed on a silver platter. This is not RentACoder. Help is offered when you post code and tell us what is wrong with it. Any error and stacktraces will help a lot.

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

Similar Threads

  1. Something easy
    By jeata in forum New To Java
    Replies: 11
    Last Post: 10-04-2010, 07:31 PM
  2. in need of help (easy)
    By fasck in forum New To Java
    Replies: 5
    Last Post: 12-30-2009, 10:45 PM
  3. how easy it is?
    By ron87 in forum New To Java
    Replies: 0
    Last Post: 04-01-2009, 06:36 PM
  4. Not so easy is it.
    By Roy Gardiner in forum Introductions
    Replies: 0
    Last Post: 10-24-2008, 04:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •