import numpy as np
try: import simplejson as json
except ImportError: import json

def process_file(fileName, mask = None, **loadtxt_kwargs):
    """Load Keysight PNA file data into dict.

    Parameters
    ----------
    fileName : string
        Path to data. Actual name of the file should be in the format:
        ``name + '_' + pwr + '_DBM_TEMP_' + temp + '.S2P'`` where:

        - name: Must be 'RES-N' where N is any single character you like.

        - pwr: The power the resonator sees in dBm, three characters Example: '-25'

        - temp: The temperature of the resonator in K, five characters Example: '0.150'

    mask : slice (optional)
        You can pass a slice to cut out some region of data. Example 1: mask = slice(10,-10) will cut out the first 10 and last 10 datapoints. Example 2: maks = slice(None,None,10) will resample your data and take every 10th point. Example 3: mask = slice(None, -50) will cut the last 50 points off your data.

    loadtxt_kwargs : dict (optional)
        This is a pass-through to numpy.loadtxt

    Returns
    -------
    dataDict : dict or ``None``
        Dictionary contains the following keys: 'name', 'temp', 'pwr', 'freq',
        'I', 'Q'. If fileName does not exist, then returns ``None``.

    Note
    ----
    This assumes the data in the file is in three columns in the order frequency, I, Q.

    This is also a terribly written function, and you really should write your own!
    """
    #Find the temperature, power, and name locations from the filename
    tempLoc = fileName.find('TEMP') + 5
    pwrLoc = fileName.find('DBM') - 4
    resNameLoc = fileName.find('RES-')

    if mask is None:
        mask = slice(None, None)
    else:
        assert type(mask) == slice, "mask must be of type slice."

    #Read the temp, pwr, and resName from the filename
    if(fileName[tempLoc + 1] == '.'):
        temp = np.float(fileName[tempLoc:tempLoc+5])

        if fileName[pwrLoc] == '_':
            pwr = np.float(fileName[pwrLoc+1:pwrLoc+3])
        else:
            pwr = np.float(fileName[pwrLoc:pwrLoc+3])

        resName = fileName[resNameLoc:resNameLoc+5]

        #Grab frequency, I, and Q
        fileData = np.loadtxt(fileName, **loadtxt_kwargs)
        freqData = fileData[:,0][mask]
        IData = fileData[:,1][mask]
        QData = fileData[:,2][mask]

        dataDict = {'name':resName,'temp':temp,'pwr':pwr,'freq':freqData,'I':IData,'Q':QData}
        return dataDict
    else:
        
        assert False, "Bad file? " + fileName
@@ -12,16 +12,37 @@
 y as np%0A
+import pandas as pd%0A%0A
 try: imp
@@ -136,16 +136,33 @@
  = None,
+ meta_only=False,
  **loadt
@@ -999,16 +999,151 @@
  data.%0A%0A
+    meta_only : bool%0A        Return just the metadata from the filename (True) or all the data (False).%0A        Default is False.%0A    %0A
     load
@@ -1251,19 +1251,8 @@
 %0A   
- dataDict :
  dic
@@ -2294,16 +2294,141 @@
 Loc+5%5D%0A%0A
+        metaDict = %7B'name':resName,'temp':temp,'pwr':pwr%7D%0A%0A        if meta_only:%0A            dataDict = %7B%7D%0A        else:%0A    
         
@@ -2453,16 +2453,20 @@
 , and Q%0A
+    
         
@@ -2523,16 +2523,20 @@
         
+  
+  
 freqData
@@ -2566,16 +2566,20 @@
         
+    
 IData = 
@@ -2606,16 +2606,20 @@
         
+  
+  
 QData = 
@@ -2639,32 +2639,36 @@
 %5Bmask%5D%0A%0A        
+    
 dataDict = %7B'nam
@@ -2668,45 +2668,8 @@
 = %7B'
-name':resName,'temp':temp,'pwr':pwr,'
 freq
@@ -2700,16 +2700,17 @@
 :QData%7D%0A
+%0A
         
@@ -2716,20 +2716,111 @@
  ret
-urn dataDict
+Val = %7B%7D%0A        retVal.update(metaDict)%0A        retVal.update(dataDict)%0A        %0A        return retVal
 %0A   

Add ability to return just metadata from process file