Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

parse filename

def parse_datastream(filename):
    splits = filename.split('.')
    datastream = '.'.join(splits[:2])
    partial_ds = splits[0]
    site = partial_ds[:3]
    for index, character in enumerate(partial_ds):
        if character.isupper():
            break
    instrument = partial_ds[3:index]
    facility = partial_ds[index:]
    level = splits[1]
    date = splits[-3]
    time = splits[-2]
    extension = splits[-1].strip()
    return_dict = {
        'datastream':datastream, 
        'site':site, 
        'instrument':instrument, 
        'facility':facility, 
        'level':level, 
        'date':date, 
        'time':time, 
        'extension':extension
    }
    return return_dict
Comment

PREVIOUS NEXT
Code Example
Python :: changing speak rate pyttsx 
Python :: how-to-add-new-column-to-an-dataframe-to-the-front-not-end 
Python :: range function without end value 
Python :: python get currentmonth 
Python :: Set symmetric Using the Symmetric Difference Operator (^) Method 
Python :: how to un register DefaultAdminSite in django 
Python :: Code Example of Comparing None with empty string 
Python :: Simple Python Permutation Printing result without for loop 
Python :: Math Module acos() Function in python 
Python :: how to return and use a single object in custom template filters django 
Python :: unique character 01 
Python :: Add 1 to loops 
Python :: django updateview not saving 
Python :: vortex core line detection 
Python :: dict keys in tcl 
Python :: godot ternary 
Python :: Python NumPy squeeze function Syntax 
Python :: Python NumPy copyto function example copy elements from a source array to a destination array. 
Python :: odoo 15 documentation 
Python :: Python NumPy asarray_chkfinite Function Example Tuple to an array 
Python :: radar chart different scales python 
Python :: assignment 8.4 python data structures 
Python :: Python how to use __ne__ 
Python :: 16. count total numbers of uppercase and lowercase characters in input string python 
Python :: URL to origin python 
Python :: # find all text files in directory or any type of files in directory 
Python :: how to avoind DeprecationWarning in python 
Python :: QDateEdit.date().toString("MMMM dd, yyyy") does not display months in English 
Python :: send by email in odoo 14 
Python :: changing labels of facetgrid 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =