parsing data in a text file 
Author Message
 parsing data in a text file

Hi there,
I have a pretty complicated file with some complex data and I have no
idea how to get what I am looking for
sample data is below
I want to be able to grab the first name of the person and match it
with the 3 first element of the first line of each set of data in the
file (NEXT is the delimiter) then get the house number(s) and put them
into an array/collection and be able to access them.
for instance
Jerry(Chicago,ZIPCODE1212, ABC_STREET) = (1244,1111)
Jerry(London ,ZIPCODE1234, JX_STREET) = (1)
DAN(Chicago,ZIPCODE1212, ABC_STREET) = (1244)
and so on..
But also I want oto be able to sum up 2d entry on each Name Line for
each city block

for instance for this block
Jerry(Chicago,ZIPCODE1212, ABC_STREET)
the sum will be 100 + 300 + 10 = 410 (sum of second entry for each
name accross the city block)
for Jerry(London ,ZIPCODE1234, JX_STREET) sum will be 200 + 300 = 500
for DAN(Chicago,ZIPCODE1212, ABC_STREET) sum will be 200
for James(Chicago,ZIPCODE1212, ABC_STREET) sum will be 230 + 30 + 20
=280
for frank(London ,ZIPCODE1234, JX_STREET) = 200

I want to be able to get the sum for the third entry on each Name line
accross the city block as well follwoing logic above.

I am wondering if there is a way to capture all this data at once then
be able to process them later in a different module.

Regards
And Thanks for your help

AL

__DATA__
London ,ZIPCODE1234, JX_STREET ,  1
Jerry  , 200 , 400
Jerry  , 300 , 200
Frank  , 100 , 300
Frank  , 100 , 200
James  , 100 , 200
NEXT
Chicago,ZIPCODE1212, ABC_STREET, 1244
Jerry  , 100 , 300
Jerry  , 300 , 100
DAN    , 200 , 20
James  , 230 , 120
Bernard, 700 , 30
NEXT
Chicago,ZIPCODE1212, ABC_STREET, 1111
Jerry  , 10  , 300
James  , 30  , 300
James  , 20  , 300
Jerry  , 10  , 300
Bernard, 10  , 300
Cesar  , 120 , 20
NEXT

__END__



Mon, 13 Sep 2004 06:59:33 GMT  
 parsing data in a text file
First things first, where are these Magic Numbers coming from?

| for Jerry(London ,ZIPCODE1234, JX_STREET) sum will be 200 + 300 = 500
| for DAN(Chicago,ZIPCODE1212, ABC_STREET) sum will be 200
| for James(Chicago,ZIPCODE1212, ABC_STREET) sum will be 230 + 30 + 20
| =280
| for frank(London ,ZIPCODE1234, JX_STREET) = 200

D?

| Hi there,
| I have a pretty complicated file with some complex data and I have no
| idea how to get what I am looking for
| sample data is below
| I want to be able to grab the first name of the person and match it
| with the 3 first element of the first line of each set of data in the
| file (NEXT is the delimiter) then get the house number(s) and put them
| into an array/collection and be able to access them.
| for instance
| Jerry(Chicago,ZIPCODE1212, ABC_STREET) = (1244,1111)
| Jerry(London ,ZIPCODE1234, JX_STREET) = (1)
| DAN(Chicago,ZIPCODE1212, ABC_STREET) = (1244)
| and so on..
| But also I want oto be able to sum up 2d entry on each Name Line for
| each city block
|
| for instance for this block
| Jerry(Chicago,ZIPCODE1212, ABC_STREET)
| the sum will be 100 + 300 + 10 = 410 (sum of second entry for each
| name accross the city block)
| for Jerry(London ,ZIPCODE1234, JX_STREET) sum will be 200 + 300 = 500
| for DAN(Chicago,ZIPCODE1212, ABC_STREET) sum will be 200
| for James(Chicago,ZIPCODE1212, ABC_STREET) sum will be 230 + 30 + 20
| =280
| for frank(London ,ZIPCODE1234, JX_STREET) = 200
|
| I want to be able to get the sum for the third entry on each Name line
| accross the city block as well follwoing logic above.
|
| I am wondering if there is a way to capture all this data at once then
| be able to process them later in a different module.
|
| Regards
| And Thanks for your help
|
| AL
|
| __DATA__
| London ,ZIPCODE1234, JX_STREET ,  1
| Jerry  , 200 , 400
| Jerry  , 300 , 200
| Frank  , 100 , 300
| Frank  , 100 , 200
| James  , 100 , 200
| NEXT
| Chicago,ZIPCODE1212, ABC_STREET, 1244
| Jerry  , 100 , 300
| Jerry  , 300 , 100
| DAN    , 200 , 20
| James  , 230 , 120
| Bernard, 700 , 30
| NEXT
| Chicago,ZIPCODE1212, ABC_STREET, 1111
| Jerry  , 10  , 300
| James  , 30  , 300
| James  , 20  , 300
| Jerry  , 10  , 300
| Bernard, 10  , 300
| Cesar  , 120 , 20
| NEXT
|
| __END__



Mon, 13 Sep 2004 07:06:03 GMT  
 parsing data in a text file

Quote:

> First things first, where are these Magic Numbers coming from?

> | for Jerry(London ,ZIPCODE1234, JX_STREET) sum will be 200 + 300 = 500
> | for DAN(Chicago,ZIPCODE1212, ABC_STREET) sum will be 200
> | for James(Chicago,ZIPCODE1212, ABC_STREET) sum will be 230 + 30 + 20
> | =280
> | for frank(London ,ZIPCODE1234, JX_STREET) = 200

> D?

They are in this file:

If we take (London ,ZIPCODE1234, JX_STREET) block

  London ,ZIPCODE1234, JX_STREET ,  1
  Jerry  , 200 , 400                    # Jerry 200  
  Jerry  , 300 , 200                    # Jerry 300
  Frank  , 100 , 300                    # Frank 100
  Frank  , 100 , 200                    # Frank 100
  James  , 100 , 200                    #James  100
  NEXT

we take the second entry on each Name's line and sum them up for a City block
Jerry sum will be 200 + 300 = 500
Frank ->100 + 100 =200
James ->100

For city block = (Chicago,ZIPCODE1212, ABC_STREET)
 Chicago,ZIPCODE1212, ABC_STREET, 1244
  Jerry  , 100 , 300      #Jerry 100
  Jerry  , 300 , 100      #Jerry 300
  DAN    , 200 , 20
  James  , 230 , 120
  Bernard, 700 , 30
  NEXT
  Chicago,ZIPCODE1212, ABC_STREET, 1111
  Jerry  , 10  , 300      #Jerry 10
  James  , 30  , 300
  James  , 20  , 300
  Jerry  , 10  , 300      #Jerry  10
  Bernard, 10  , 300
  Cesar  , 120 , 20
  NEXT
sum for Jerry will be 100 + 300 + 10 + 10 = 420
and so on for the other Names.

I hope I am a little clearer this time

Thanks

AL



Mon, 13 Sep 2004 22:02:21 GMT  
 parsing data in a text file
You can read a line of data from a text file, then use the
"Split"
function to parse it into an array if it has a common
delimitter.

--
________________________________________________________________

Falls Church, {*filter*}ia                        703-560-7380
________________________________________________________________

Quote:
> Hi there,
> I have a pretty complicated file with some complex data and I
have no
> idea how to get what I am looking for
> sample data is below
> I want to be able to grab the first name of the person and
match it
> with the 3 first element of the first line of each set of data
in the
> file (NEXT is the delimiter) then get the house number(s) and
put them
> into an array/collection and be able to access them.
> for instance
> Jerry(Chicago,ZIPCODE1212, ABC_STREET) = (1244,1111)
> Jerry(London ,ZIPCODE1234, JX_STREET) = (1)
> DAN(Chicago,ZIPCODE1212, ABC_STREET) = (1244)
> and so on..
> But also I want oto be able to sum up 2d entry on each Name
Line for
> each city block

> for instance for this block
> Jerry(Chicago,ZIPCODE1212, ABC_STREET)
> the sum will be 100 + 300 + 10 = 410 (sum of second entry for
each
> name accross the city block)
> for Jerry(London ,ZIPCODE1234, JX_STREET) sum will be 200 +
300 = 500
> for DAN(Chicago,ZIPCODE1212, ABC_STREET) sum will be 200
> for James(Chicago,ZIPCODE1212, ABC_STREET) sum will be 230 +
30 + 20
> =280
> for frank(London ,ZIPCODE1234, JX_STREET) = 200

> I want to be able to get the sum for the third entry on each
Name line
> accross the city block as well follwoing logic above.

> I am wondering if there is a way to capture all this data at
once then
> be able to process them later in a different module.

> Regards
> And Thanks for your help

> AL

> __DATA__
> London ,ZIPCODE1234, JX_STREET ,  1
> Jerry  , 200 , 400
> Jerry  , 300 , 200
> Frank  , 100 , 300
> Frank  , 100 , 200
> James  , 100 , 200
> NEXT
> Chicago,ZIPCODE1212, ABC_STREET, 1244
> Jerry  , 100 , 300
> Jerry  , 300 , 100
> DAN    , 200 , 20
> James  , 230 , 120
> Bernard, 700 , 30
> NEXT
> Chicago,ZIPCODE1212, ABC_STREET, 1111
> Jerry  , 10  , 300
> James  , 30  , 300
> James  , 20  , 300
> Jerry  , 10  , 300
> Bernard, 10  , 300
> Cesar  , 120 , 20
> NEXT

> __END__



Wed, 15 Sep 2004 01:34:51 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Parsing data from text and html files

2. Help parse a text string from sequential text file

3. Parse data within text strings

4. Reading and Parsing Text Files (FileSystemObject)?

5. Reading and parsing a text file from VBA

6. parse form a text file to an Outlook form

7. Parsing Email addresses from a text file

8. Open and parse a text file.

9. basic question about parsing text files

10. Parsing Tags from a text file

11. Parsing Text file

12. Parsing plain text file

 

 
Powered by phpBB® Forum Software