Note: The Listed platform will permanently shut down December 31, 2026. Your data published on Listed will still be available in your personal Standard Notes account. Learn more

Python Snippets

Python Snippets

Get CWD

current_dir = Path.cwd()
print(current_dir)  #or   print(current_dir.name) #only the folder name (without the rest of the path)

Load a single variable from a .mat file

def GetValueFromMatFile(varName):
    data = read_mat('phase1.mat', varName)
    return data[varName]

C = GetValueFromMatFile('C')
print(f"C is {C}")

f String Examp[le

    print(f"RSS: {RSS:3.5f}dBm")

List .mat files in a folder, open one and list it's contents

current_dir = Path.cwd()
print(current_dir)  #or   print(current_dir.name) #only the folder name (without the rest of the path)

mat_files = [f.name for f in Path('.').glob('*.mat') if f.is_file()]
print(mat_files)

data = read_mat('phase1.mat','C')
print(data.keys())




You'll only receive email when they publish something new.

More from Brad G
All posts