Index: trunk/tools/OBSstations.csv
===================================================================
--- trunk/tools/OBSstations.csv	(revision 2731)
+++ trunk/tools/OBSstations.csv	(revision 2732)
@@ -1,3 +1,3 @@
-#WMOid,station_name,longitude,latitude,lon_deg,lon_min,lon_sec,lat_deg,lat_min,lat_sec,height,country,prov,nice_name,add1,add2
+#station_name,WMOid,longitude,lon_deg,lon_min,lon_sec,latitude,lat_deg,lat_min,lat_sec,height,prov,country,nice_name,add1,add2
 AEROPARQUE BUENOS AIRES,87582,34.566667,34,34,0.00,58.416667,58,25,0.00,6,CAPITAL FEDERAL,Argentina,Aeroparque Airport Buenos Aires,,
 BUENOS AIRES,87585,34.583333,34,35,0.00,58.483333,58,29,0.00,25,CAPITAL FEDERAL,Argentina,Buenos Aires,,
Index: trunk/tools/generic_tools.py
===================================================================
--- trunk/tools/generic_tools.py	(revision 2731)
+++ trunk/tools/generic_tools.py	(revision 2732)
@@ -233,4 +233,6 @@
 # snr_K08: Function to compute the signal-to-noise-ratio after Kendon et al., 2008
 # stagger_unstagger: Function to de-stagger a variable
+# stations_values: Function to provide information from a given station from one of its values 
+#   from ASCII file 'OBStations.csv'
 # stats_Slist: Function to provide extremes from a string as a list separated by a given character
 # std_stats2Val: two variables standard Statistics class 
@@ -5864,4 +5866,6 @@
         elif typeval == 'str' or typeval == 'S':
             return str(value)
+        elif typeval == 'unicode' or typeval == 'U':
+            return value.decode("utf-8", "strict")
         elif typeval == 'bool':
             return bool(value)
@@ -17254,49 +17258,60 @@
 
     newlist = []
-    for iv in range(Nin): newlist.append(typemod(inlist[iv], Klist[iv]))
+    for iv in range(Nin): 
+        if len(inlist[iv]) > 0: 
+            newlist.append(typemod(inlist[iv], Klist[iv]))
+        else:
+            newlist.append(' ')
 
     return newlist
 
-print list_listKs(['2.2333', 'Hola', '231.21', '231.21'], ['F', 'S', 'F-I', 'D'])
-
-quit()
-
-def stations_values(stcrit,stval):
+def stations_values(stcrit,stval,Nexpctst='all'):
     """ Function to provide information from a given station from one of its values 
       from ASCII file 'OBStations.csv'
     variables_values([values])
         [stcrit]: name of the criteria from OBStations.csv
-          one of: 'WMOid', 'station_name', 'longitude', 'latitude', 'lon_deg',         
-          'lon_min', 'lon_sec', 'lat_deg', 'lat_min', 'lat_sec', 'height', 'country', 
-          'prov', 'nice_name', 'add1', 'add2'
+          one of: 'station_name', 'WMOid', 'longitude', 'lon_deg', 'lon_min', 
+          'lon_sec', 'latitude', 'lat_deg', 'lat_min', 'lat_sec', 'height', 
+          'prov', 'country', 'nice_name', 'add1', 'add2'
+          [station_name]: station raw name 
           [WMOid]: WMO id value
-          [station_name]: station raw name 
           [longitude]: longitude of the station in degrees
-          [latitude]: latitude of the stations in degrees
           [lon_deg]: longitude degree of the station
           [lon_min]: longitude minute of the station
           [lon_sec]: longitude second of the station
+          [latitude]: latitude of the stations in degrees
           [lat_deg]: latitude degree of the station
           [lat_min]: latitude mniute of the station
           [lat_sec]: latitude second of the station
           [height]: height of the station
+          [prov]: province/state/...
           [country]: country of the station
-          [prov]: province/state/...
           [nice_name]: Complete nice name of the station
           [add1]: additional value 1
           [add2]: additional value 2
         [stval]: value of [stcrit] to be matched
-        return: [WMOid], [station_name], [longitude], [latitude], [lon_deg],         
-          [lon_min], [lon_sec], [lat_deg], [lat_min], [lat_sec], [height], [country], 
-          [prov], [nice_name], [add1], [add2]
-    >>> variables_values('WMOid','87582')
-
+        [Nexpctst]: expected quantity of stations to retrieve
+          'all': all matching entries. It will return a dictionary
+          'one': only one entry. It will return a list
+        return: [station_name], [WMOid], [longitude], [lon_deg], [lon_min], [lon_sec], 
+          [latitude], [lat_deg], [lat_min], [lat_sec], [height], [prov], [country], 
+          [nice_name], [add1], [add2]
+    >>> stations_values('WMOid','87582','all')
+    {0: ['AEROPARQUE BUENOS AIRES', 87582, 34.566667, 34, 34, 0.0, 58.416667, 58, 
+       25, 0.0, 6.0, u'CAPITAL FEDERAL', u'Argentina',
+       u'Aeroparque Airport Buenos Aires', ' ', ' ']}
+    >>> stations_values('WMOid','87582','one')
+    ['AEROPARQUE BUENOS AIRES', 87582, 34.566667, 34, 34, 0.0, 58.416667, 58, 
+       25, 0.0, 6.0, u'CAPITAL FEDERAL', u'Argentina', 
+       u'Aeroparque Airport Buenos Aires', ' ', ' ']
     """
     import subprocess as sub
     fname='stations_values'
 
-    criteriavail = ['WMOid', 'station_name', 'longitude', 'latitude', 'lon_deg',     \
-          'lon_min', 'lon_sec', 'lat_deg', 'lat_min', 'lat_sec', 'height', 'country',\
-          'prov', 'nice_name', 'add1', 'add2']
+    criteriavail = ['station_name', 'WMOid', 'longitude', 'lon_deg', 'lon_min',      \
+      'lon_sec', 'latitude', 'lat_deg', 'lat_min', 'lat_sec', 'height', 'prov',      \
+      'country', 'nice_name', 'add1', 'add2']
+    stKs = ['S', 'I', 'F', 'I', 'I', 'F', 'F', 'I', 'I', 'F', 'F', 'U', 'U', 'U',    \
+      'U', 'U']
 
     if stcrit == 'h':
@@ -17324,6 +17339,7 @@
         quit(-1)
     icrit = criteriavail.index(stcrit)
+    stv = typemod(stval,stKs[icrit])
+    Nst = 0
     stations = {}
-    Nst = 0
     for line in ncf:
         if line[0:1] != '#' and len(line) > 10:
@@ -17335,13 +17351,30 @@
                 quit(-1)
 
-            if values[icrit] == stval:                
-                stations[Nst] = [int(values[0]), values[1]]
-
-    print errormsg
-    print '  ' + fname + ": variable '" + varn + "' not defined !!!"
-    ncf.close()
-    quit(-1)
-
-    return 
+            stvalues = list_listKs(values, stKs)
+            print stvalues[icrit], stv, stvalues[icrit] == stv
+            if stvalues[icrit] == stv: 
+                stations[Nst] = stvalues
+                Nst = Nst + 1
+
+    if Nst == 0:
+        print errormsg
+        print '  ' + fname + ": station with criteria '" + stcrit + "'= '", stval,   \
+          "' not found !!!"
+        ncf.close()
+        quit(-1)
+
+    if Nexpctst == 'all': return stations
+    else: 
+        if Nst > 1:
+            print errormsg
+            print '  ' + fname + ': too many stations found ', Nst, '!!'
+            print '    ', Nst, 'stations found _______'
+            printing_dictionary(stations)
+        else: 
+            stfound = stations[0]
+            return stfound
+
+
+    return stations
 
 #quit()
