This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Parsing NOAA weather report project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Parsing NOAA weather report project" Watch "Parsing NOAA weather report project" New topic
Author

Parsing NOAA weather report project

Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
Hi,
I'm looking for some design ideas for a project I'm working on: parsing and plotting NOAA weather report texts.
The current problem is parsing the day/times for the report. There are many formats for the day/times. I have a tokenizer that returns the next word from the report. So far I have an awful mess of if else if and nested ifs to try to parse the input. I haven't studied computer science techniques for years and was wondering if anyone could give me some design ideas. The only technique that I can think of is a finite state machine.
Then the syntax would be in a table instead of the mass of if else ifs.

Here are some sample days/times from the NOAA weather texts:
today and tonight
thu and thu night
tonight
mon night
today through fri
this afternoon and tonight
this afternoon
tonight
wed night and thru

These strings are then followed optionally by a wind report, a hurricane report, a seas report or comment of some kind.
I am using the PushbackReader class so that I can read ahead to find the beginning of the next report, recognize the end of the current report and push back the parts of the next report.

Thanks,
Norm

Here's a sample of what I mean by a FSM. Some methods are dummies:
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

I take it you are parsing the plain text forecast? That would be painful. NOAA forecasts are also available in xml format which would be much easier to work with.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
Joe,
Thanks for the link. I looked at the site and find that NOAA doesn't include the area I'm interested in in its database (Caribbean sea). Also there output is for single locations and not for areas.
So back to parsing.

How did you happen to know about the NOAA XML site?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

I made a weather alert app last year and went through NOAA's data with a fine tooth comb. There was something weird with the previous web data product, like they had a place holder for hurricane warnings for Ohio but no severe thunderstorm warnings (which, of course, are far more likely in the midwest). I turned the site inside out trying to see the logic of it. They had information about the XML feeds, but they weren't live at that time. They would have saved me a lot of trouble.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Parsing NOAA weather report project
 
Similar Threads
Parsing xml file using sax parser-NULLPOINTEREXCEPTION
Objects and Constructs.
Java Collections and the Iterator Pattern
how can i get the referance of the abstract class
Name, Address & Date Matching