Changeset 2733 in lmdz_wrf


Ignore:
Timestamp:
Oct 25, 2019, 6:34:17 PM (5 years ago)
Author:
lfita
Message:

Adding:

  • `list_rmchar': Function to remove a list of characters from its values
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r2732 r2733  
    175175#    a list of type of values
    176176# list_norepeatcombos: Function to all possible (Num-1)-combinations of a Num values without repetitions
     177# list_rmchar: Function to remove a list of characters from its values
    177178# lstring_values: Function to provide a new list-string from a string which is a list of word separated by a character if some values are repeated they are not included
    178179# lonlat_dist: Function to provide the distance in m between two lon,lat coordinates
     
    1737817379    return stations
    1737917380
     17381def list_rmchar(listv, rmchr):
     17382    """ Function to remove a list of characters from its values
     17383      listv: list of values
     17384      rmchr: list of characters to remove
     17385    >>> list_rmchar([' ', ' ', ' Ezeiza', ' Aero '], [' '])
     17386    ['Ezeiza', 'Aero']
     17387    """
     17388    fname = 'list_rmchar'
     17389
     17390    newlist = []
     17391    Nl = len(listv)
     17392    Nrm = len(rmchr)
     17393    for iv in range(Nl):
     17394        Sv = str(listv[iv])
     17395        for ic in range(Nrm):
     17396            Sv = Sv.replace(rmchr[ic],'')
     17397        if len(Sv) > 0: newlist.append(Sv)
     17398
     17399    return newlist
     17400
    1738017401#quit()
    1738117402
Note: See TracChangeset for help on using the changeset viewer.