Results 1 to 3 of 3

Thread: Splitting Data [resolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    492

    Resolved Splitting Data [resolved]

    I have the following data(these are just three lines of the file that i am reading in) that I need to split up and put into an array. Its date, worker name with id number, followed by hours worked each day for the entire week.

    Code:
    11/03/06          John Doe 4335         40-42-40-32-40
    11/03/06          Jason Doe 2233       40-2-9
    11/03/06          Jane Doe 8831        12-17
    There are about 2-15 spaces between Data and Name and about the same between the last number of the id and the hours worked.

    I need to put date, name & id, and hours into an array. How do I go about dividing up the data so that i can insert it into an array?


    Any help is appreciated.
    Last edited by mrstuff68; Nov 14th, 2006 at 09:59 AM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Splitting Data

    Well, it's a simple whitespace-separated format. Every line has 5 fields, separated by any amount of whitespace.
    So what you do is, you read in a line, then you use any of several splitting methods Java provides to split it into its parts. Then you parse each part (converting the date to a Date instance, converting the ID to a number, etc.) and store it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    492

    Re: Splitting Data

    Thanks, i decided to do a split on the spaces.

Posting Permissions

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



Click Here to Expand Forum to Full Width