From: "Simon Kröger" Date: 2006-04-14T07:06:54+09:00 Subject: Re: Metar Weather Grabber Chris Winslett wrote: > I don't want to pay money to get weather feeds from a bunch of different > countries. So I took my hand at writing my own. It is for an ajax > service that grabs the XML. > > If you use this, expand on it. If you expand on it, post it back on > here. There are somethings I haven't gotten to yet. The usage of the > weather codes needs to get better too. Hi Chris, is there something wrong with the decoded data? ---------------------------------------------------------------------- require 'open-uri' url = 'ftp://weather.noaa.gov/data/observations/metar/decoded/KLGA.TXT' open(url) do |f| weather = f.read.to_a.map {|line| line.strip.split(':')} label = weather.shift.first.split(',').first date = weather.shift.first puts %Q[] weather.each do |w| key = w.first.tr('()', ' ').delete(' ') puts %Q[ <#{key}>#{w[1].strip}] end puts '' end ---------------------------------------------------------------------- output: ---------------------------------------------------------------------- from the NW (320 degrees) at 9 MPH (8 KT) 10 mile(s) partly cloudy 75.0 F (23.9 C) 35.1 F (1.7 C) 23% ... ---------------------------------------------------------------------- cheers Simon