Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Easy App CSV

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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, wikipedia, +,
    beer, 27300000, Google Universal Italy, 2, birra, +,
    beer, 27300000, Google Universal Italy, 3, albanesi, +
    ale, 7300000, Google Universal Italy, 1, wikipedia, +,
    ale, 7300000, Google Universal Italy, 2, birra, +,
    ale, 7300000, Google Universal Italy, 3, albanesi, +
    dark beer, 300000, Google Universal Italy, 1, wikipedia, +,
    dark beer, 300000, Google Universal Italy, 2, birra, +,
    dark beer, 300000, Google Universal Italy, 3, albanesi, +



    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
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    592
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Easy App CSV

    What have you tried? - Matt Gemmell

    Nobody will do it for you. Post your best attempt and ask specific questions.

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Easy App CSV

    I understand how to read a CSV but I do not understand how to be able to assign scores and do the ranking, I have to use a database or can I do without it?
    [
    import java.io.*;
    import java.util.Arrays;

    public class CSVRead{

    public static void main(String[] arg) throws Exception {

    BufferedReader CSVFile = new BufferedReader(new FileReader("C:\\birra.csv"));

    String dataRow = CSVFile.readLine(); // Read the first line of data.
    // The while checks to see if the data is null. If it is, we've hit
    // the end of the file. If not, process the data.
    while (dataRow != null){
    String[] dataArray = dataRow.split(",");
    for (String item:dataArray) { System.out.print(item + "\t"); }
    System.out.println(); // Print the data line.
    dataRow = CSVFile.readLine(); // Read next line of data.
    }

    // Close the file once all data has been read.
    CSVFile.close();

    // End the printout with a blank line.
    System.out.println();

    } //main()
    } // CSVRead
    ]

  4. #4
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    592
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Easy App CSV

    You haven't specified how those scores should be calculated. You don't store the data from the csv file anywhere in memory, so there's nothing left to do calculations with.

  5. #5
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Easy App CSV

    Yeah I know that in my code I do not save the data, I do not know how to do it.
    Scores are awarded based on the location field:
    position 1 = 30 points
    position 2 = 20 points ecc

Similar Threads

  1. csv or text file to Multiple csv or text file
    By robert1994 in forum What's Wrong With My Code?
    Replies: 17
    Last Post: April 19th, 2013, 01:35 PM
  2. reading csv by scanner
    By takamine in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: February 22nd, 2013, 09:41 AM
  3. JTable Edit to .csv
    By mazaoa in forum AWT / Java Swing
    Replies: 1
    Last Post: January 14th, 2013, 07:42 AM
  4. My app audio sounds different when running the app?
    By TP-Oreilly in forum Android Development
    Replies: 1
    Last Post: January 29th, 2012, 07:23 AM
  5. Need help outputting the array to a .csv
    By arpanetguru in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: November 23rd, 2010, 04:27 PM