The Artima Developer Community
Sponsored Link

Java Answers Forum
Experiment

2 replies on 1 page. Most recent reply: Jul 25, 2003 8:28 AM by David Smallwood

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
David Smallwood

Posts: 2
Nickname: mudway
Registered: Jul, 2003

Experiment Posted: Jul 25, 2003 4:54 AM
Reply to this message Reply
Advertisement
Dear Sirs/Madam

I have some experimental data in an ASCII file from which I'm trying to construct some hash tables from and then do some statistical analysis/calculations. This is for a scientific experiment. I have made an attempt at writing a simple parser by writing a class that reads data in from the file.

1) What I want to be able to do is parse this data so that it dynamically builds up a hash table with the key of the table being an id (i.e which is found in column 4 of the ascii file).

2) I want to be able to keep a tally/count for each individual ID (i.e. 4th column) the number of times a particular activity which is described by a string (i.e 7th column) occurs. I want to store this as a data value in a vector.

(I have code which parses the file. However, I want to count the number of times (i.e. frequency) a particluar ID does an activity and store this as a value in a vector under each appropriate activity.)

This is the format of the ASCII file:

13052003 11:30:18 82575 f40311bffb 331981 2.8 Paging response
13052003 11:30:22 82881 f41ae2d242 33 12.2 Normal location update+authentication
13052003 11:30:28 84594 f400551875 33 4.4 Periodic location update
13052003 11:30:54 90333 f49183d234 33 5.5 Periodic location update
13052003 11:30:56 90659 f489815398 33 5.5 Periodic location update
13052003 11:30:57 90996 2943016406401280 331981 1.1 Paging response
13052003 11:31:15 94815 f424a4ac13 331981 5.5 Paging response
13052003 11:32:23 109615 f47d005bd9 331981 1.7 Service request mobile call
13052003 11:32:27 110421 f465644163 331981 2.2 Service request mobile call
13052003 11:32:31 111237 f4689278c7 331981 11.6 Service request mobile call
13052003 11:32:55 116577 f447035857 335981 12.7 Service request mobile call
13052003 11:32:57 116796 2943012109009630 33 12.7 Normal location update+authentication
13052003 11:33:16 121080 f420061d94 331981 5.5 Paging response
13052003 11:34:28 136686 f48603ea6c 33 5.5 IMSI attach
13052003 11:34:33 137502 f41ff1b5bb 331981 3.3 Service request mobile call+authentication
13052003 11:35:07 145172 f486935fb4 331981 1.7 Paging response
13052003 11:35:15 146835 f44ab34924 33 2.2 Periodic location update


Column fields explained:-

column 1 is a Date value.
column 2 is a Time.
column 3 is a Frame Number.
column 4 is the ID e.g. 2943016406401280 or f40311bffb
column 5 is an Integer
Column 6 is a Float
Column 7 is a String for describing an Activity

In summary, what I want to end up with is a hash table that looks something like this which can be printed to the console:

ID IMSI Attach IMSI Detach Periodic location update Normal location update Serv. Req. M O Serv. Req. SMS

f4aed364b9 0 0 8 0 0 8
f49bb0f30f 0 0 43 0 0 0


I want to store these counts in vectors because I want to be able to do some calculations on this data later on. Any help much appreciated.


zenykx

Posts: 69
Nickname: zenykx
Registered: May, 2003

Re: Experiment Posted: Jul 25, 2003 5:42 AM
Reply to this message Reply
If i understand well you want to use the column 4 string as a key of a HashMap, but in the same time these values are not unique (?). So, when a new line containing the same column 4 value will be reached the old value will be lost.
I dont really understand what is the problem. Create a class which contains as fields the columns in your test data, create pairs ID - class in your hashmap, put every string in column 7 in another hashmap in order to count the number of apparition and finally make your class display its contents in the format you want.

David Smallwood

Posts: 2
Nickname: mudway
Registered: Jul, 2003

Re: Experiment Posted: Jul 25, 2003 8:28 AM
Reply to this message Reply
I understand what you mean. I want to keep a total of all the times the column 4 value does a particular activity e.g. f402f0e364 does IMSI Attach activity 0 times altogether in the file....

thanks.

Flat View: This topic has 2 replies on 1 page
Topic: MenuBar help!!! Previous Topic   Next Topic Topic: String Counting

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use