Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7665023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:27:16+00:00 2026-05-31T14:27:16+00:00

I have a problem with writting this program I need to read a csv

  • 0

I have a problem with writting this program

I need to read a csv file and write it to binary then read it again. I has to be written in this way:

Field name Data type
Name First Text
Name Last Text
Birth Day Whole number
Birth Month Whole number
Birth Year 4-digit year
Weight Whole number
Height Number with decimal part

I now how to read csv and binary, but how to do this is a mistery to me.

What toubles me the most is that in this csv first line is just strings and then coninues name lastname and so on

namefirst namelast birthday birthmonth birthyear weight height

Starlin Castro 243199019072.8
Madison Bumgarner 18198921576.0
Jason Heyward 98198924077.3
Ruben Tejada 2710198916071.2
Jenrry Mejia 1110198916072.5
Mike Stanton 811198923577.9
Dayan Viciedo 103198924071.1
Chris Sale 303198917077.2
Freddie Freeman 129198922577.7
Clayton Kershaw 193198822575.4
Travis Snider 22198823572.0
Elvis Andrus 268198820072.0
Trevor Cahill 13198822076.0
Rick Porcello 2712198820077.0
Brett Anderson 12198823576.5
Fernando Martinez 1010198820073.0
Jhoulys Chacin 71198821575.2
Chris Tillman 154198820077.8
Neftali Feliz 25198821575.5
Craig Kimbrel 285198820571.6

Can you help me?

this is my code till now

I can read it line by line but how to continue now?

public static void main(String[] args) {

 try
 {

                //csv file containing data
    String strFile = "BaseballNames1.csv";

                //create BufferedReader to read csv file
    BufferedReader br = new BufferedReader( new FileReader(strFile));
    String strLine = "";
    StringTokenizer st = null;
    int lineNumber = 0;
    int tokenNumber = 0;

                //read comma separated file line by line
    while( (strLine = br.readLine()) != null)
    {
       lineNumber++;

                        //break comma separated line using ","
       st = new StringTokenizer(strLine, ",");

       while(st.hasMoreTokens())
       {
                                //display csv values
          tokenNumber++;
                      /*                                                      

          String name = dis.readUTF();
          String lastName = dis.readUTF();
          int bDay = dis.readInt();
          int bMonth = dis.readInt();
          int bYear = dis.readInt();
          int weight = dis.readInt();
          double height = dis.readDouble();         */          



             System.out.println("tokel line:"+st.nextToken());  




       }

                        //reset token number
       tokenNumber = 0;

    }


 }
    catch(Exception e)
    {
       System.out.println("Exception while reading csv file: " + e);                  
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:27:17+00:00Added an answer on May 31, 2026 at 2:27 pm

    I don’t see commas in your input so breaking it on commas should probably be changed to breaking a line on spaces instead. I also see only one large float number where the heading line has five numbers specified. So generally you’re going to need to clarify what’s going in and what needs to come out.

    Tell me this isn’t homework.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into a problem while writing my server program. I need to
I am working on a binary file transfer program in which the client has
I think I have a problem with my makefile. I'm writing this program: Q2.cpp
I have a asp.net page I'm writing and I'm perplexed by this problem. I
i have this problem: starting from an empty list (0 elements) i want check
I read this topic, but his problem maybe different from mine Writing to both
Problem I have a file which contains such text (nothing else) 2010-10-05 I would
I have written down a program in c and I am trying to create
I have a log file that continually logs short lines. I need to develop
I have a program that fork() s a new process and then overwrites that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.