borexino
01-04-2007, 14:18
Salve!
Ho questo problema:
Devo leggere dei valori stringa contenuti in un file di testo esterno reperibile al seguente url http://www.sec.noaa.gov/ftpdir/latest/dayind.txt
il file txt è questo e si aggiorna in automatico
:Product: Daily Space Weather Indices dayind.txt
:Issued: 2007 Apr 01 0615 UT
# Prepared by the US Dept. of Commerce, NOAA, Space Environment Center
# Product description and SEC contact on the Web
# http://www.sec.noaa.gov/wwire.html
#
# Daily Space Weather Indices
#
#
:Solar_Indices: 2007 Mar 31
# SWO Sunspot Penticton Radio 90-day Radio GOES-12 X-ray Stanford Solar
# Number Flux 10.7cm Flux 10.7cm Bkgd Flux Mean Field
15 73 78 A0.0 -999
#
:Solar_Region_Data: 2007 Mar 31
# --------- Flares ---------
# Sunspot Area New Spotted X-ray Optical
# 10E-6 Hemis. Regions Region C M X S 1 2 3 4
20 0 1 0 0 0 1 0 0 0 0
#
:Solar_Radio_Flux: 2007 Mar 31
# Learmonth San Vito Sag Hill Penticton Penticton Palehua Penticton
# 0400 1100 1600 1700 2000 2200 2300
245 12 9 9 -1 -1 -1 -1
410 27 21 24 -1 -1 -1 -1
610 36 -1 31 -1 -1 -1 -1
1415 43 36 42 -1 -1 -1 -1
2695 70 76 70 -1 -1 -1 -1
2800 -1 -1 -1 73 73 -1 73
4995 123 132 130 -1 -1 -1 -1
8800 228 224 219 -1 -1 -1 -1
15400 517 469 447 -1 -1 -1 -1
#
:Particle_Data: 2007 Mar 31
# GOES-11 Proton Flux GOES-12 Electron Flux GOES12 Neutron
# ---- Protons/cm2-day-sr ---- - Electrons/cm2-da-sr - Location Monitor
# ->1 MeV >10 MeV >100 MeV >0.6 MeV >2 MeV West % of bkgd
1.61e+06 1.65e+04 3.74e+03 3.70e+09 4.80E+06 75 99.9
#
:Geomagnetic_Indices: 2007 Mar 31
# Middle Latitude Middle Latitude
# ----- Fredericksburg ----- --------- Boulder ---------
# A K-indices A K-indices
# 03-06-09-12-15-18-21-24 03-06-09-12-15-18-21-24
2 0 0 1 1 1 0 1 2 3 0 0 1 1 2 1 0 3
# High Latitude Estimated
# --------- College --------- -------- Planetary --------
# A K-indices A K-indices
# 03-06-09-12-15-18-21-24 03-06-09-12-15-18-21-24
3 0 0 0 3 1 1 0 1 3 1 0 0 1 1 1 0 3
Quello che mi occorre è uno script che legga il file e restituisca solo il valore evidenziato nel quote (in questo caso 15).
Io sto provando ad utilizzare il seguente codice con scarsi risultati:
//inizio lettura SSN
if (($handle = fopen ("http://www.sec.noaa.gov/ftpdir/latest/dayind.txt", "r")) !== FALSE)
{
while (($line = fgets ($handle, 4096)) !== FALSE)
{
if (strncmp ($line, "# Number", 10) == 0) //SUNSPOTNUMBER
$ssn = substr ($line, 0,500); //stampa tutta la linea
}
fclose ($handle);
}
echo $ssn;
Come posso fare? :help:
ciao
Ho questo problema:
Devo leggere dei valori stringa contenuti in un file di testo esterno reperibile al seguente url http://www.sec.noaa.gov/ftpdir/latest/dayind.txt
il file txt è questo e si aggiorna in automatico
:Product: Daily Space Weather Indices dayind.txt
:Issued: 2007 Apr 01 0615 UT
# Prepared by the US Dept. of Commerce, NOAA, Space Environment Center
# Product description and SEC contact on the Web
# http://www.sec.noaa.gov/wwire.html
#
# Daily Space Weather Indices
#
#
:Solar_Indices: 2007 Mar 31
# SWO Sunspot Penticton Radio 90-day Radio GOES-12 X-ray Stanford Solar
# Number Flux 10.7cm Flux 10.7cm Bkgd Flux Mean Field
15 73 78 A0.0 -999
#
:Solar_Region_Data: 2007 Mar 31
# --------- Flares ---------
# Sunspot Area New Spotted X-ray Optical
# 10E-6 Hemis. Regions Region C M X S 1 2 3 4
20 0 1 0 0 0 1 0 0 0 0
#
:Solar_Radio_Flux: 2007 Mar 31
# Learmonth San Vito Sag Hill Penticton Penticton Palehua Penticton
# 0400 1100 1600 1700 2000 2200 2300
245 12 9 9 -1 -1 -1 -1
410 27 21 24 -1 -1 -1 -1
610 36 -1 31 -1 -1 -1 -1
1415 43 36 42 -1 -1 -1 -1
2695 70 76 70 -1 -1 -1 -1
2800 -1 -1 -1 73 73 -1 73
4995 123 132 130 -1 -1 -1 -1
8800 228 224 219 -1 -1 -1 -1
15400 517 469 447 -1 -1 -1 -1
#
:Particle_Data: 2007 Mar 31
# GOES-11 Proton Flux GOES-12 Electron Flux GOES12 Neutron
# ---- Protons/cm2-day-sr ---- - Electrons/cm2-da-sr - Location Monitor
# ->1 MeV >10 MeV >100 MeV >0.6 MeV >2 MeV West % of bkgd
1.61e+06 1.65e+04 3.74e+03 3.70e+09 4.80E+06 75 99.9
#
:Geomagnetic_Indices: 2007 Mar 31
# Middle Latitude Middle Latitude
# ----- Fredericksburg ----- --------- Boulder ---------
# A K-indices A K-indices
# 03-06-09-12-15-18-21-24 03-06-09-12-15-18-21-24
2 0 0 1 1 1 0 1 2 3 0 0 1 1 2 1 0 3
# High Latitude Estimated
# --------- College --------- -------- Planetary --------
# A K-indices A K-indices
# 03-06-09-12-15-18-21-24 03-06-09-12-15-18-21-24
3 0 0 0 3 1 1 0 1 3 1 0 0 1 1 1 0 3
Quello che mi occorre è uno script che legga il file e restituisca solo il valore evidenziato nel quote (in questo caso 15).
Io sto provando ad utilizzare il seguente codice con scarsi risultati:
//inizio lettura SSN
if (($handle = fopen ("http://www.sec.noaa.gov/ftpdir/latest/dayind.txt", "r")) !== FALSE)
{
while (($line = fgets ($handle, 4096)) !== FALSE)
{
if (strncmp ($line, "# Number", 10) == 0) //SUNSPOTNUMBER
$ssn = substr ($line, 0,500); //stampa tutta la linea
}
fclose ($handle);
}
echo $ssn;
Come posso fare? :help:
ciao