PEATDB/Ekin/sparky.py
def read_all(parentwin,dir,pattern):
    """Read all Sparky peak files in dir that match pattern"""
    import os, re
    files=os.listdir(dir)
    okfiles=[]
    files.sort()
    for file in files:
        if file.find(pattern)!=-1 and file[0]!='.':
            okfiles.append(os.path.join(dir,file))
    print 'files to be used:',okfiles 
    columns=None
    
    # Loop over all files and get peaks    
    dict={}
    regex = "\d+\.\d+"

    for file in okfiles:        
        # Get the pH from the filename        
        filename=os.path.split(file)[-1]
        match = re.findall(regex,filename)
        try:
            pH = float(match[0])
        except:
            'Could not extract the pH from filename'
        
        #Read the file and get the peaks        
        dict[pH]=read_peaks(file)        
    return dict
Read all Sparky peak files in dir that match pattern
Read all Sparky peak files in dir that match pattern
Read all Sparky peak files in dir that match pattern
def read_all(parentwin,dir,pattern):
    import os, re
    files=os.listdir(dir)
    okfiles=[]
    files.sort()
    for file in files:
        if file.find(pattern)!=-1 and file[0]!='.':
            okfiles.append(os.path.join(dir,file))
    print 'files to be used:',okfiles 
    columns=None
    dict={}
    regex = "\d+\.\d+"
    for file in okfiles:        
        filename=os.path.split(file)[-1]
        match = re.findall(regex,filename)
        try:
            pH = float(match[0])
        except:
        dict[pH]=read_peaks(file)        
    return dict
def read_all ( parentwin , dir , pattern ) : import os , re files = os . listdir ( dir ) okfiles = [ ] files . sort ( ) for file in files : if file . find ( pattern ) != - 1 and file [ 0 ] != '.' : okfiles . append ( os . path . join ( dir , file ) ) print 'files to be used:' , okfiles columns = None dict = { } regex = "\d+\.\d+" for file in okfiles : filename = os . path . split ( file ) [ - 1 ] match = re . findall ( regex , filename ) try : pH = float ( match [ 0 ] ) except : 'Could not extract the pH from filename' dict [ pH ] = read_peaks ( file ) return dict
Read all Sparky peak files in dir that match pattern
Read all Sparky peak files in dir that match pattern
"""Read all Sparky peak files in dir that match pattern""" # Loop over all files and get peaks     # Get the pH from the filename         'Could not extract the pH from filename' #Read the file and get the peaks        
parentwin
dir
pattern