UT330BUI/view/readsave.py
def callback_write_to_disk(self):
        """Callback method for Write to disk"""

        df = pd.DataFrame(self.controller.device_data)

        if df.empty:
            self.status.text = ("Can't write data to UT330B because "
                                "there's no data to write.")
            return

        df['Timestamp'] = pd.to_datetime(df['Timestamp'])
        time_str = df['Timestamp'].max().strftime("%Y%m%d_%H%M%S")

        # Check folder exists, if not, create it        
        dir_path = os.path.dirname(os.path.realpath(__file__))
        dir_path = os.path.dirname(dir_path)
        folder = os.path.join(dir_path, 'data')
        if not os.path.isdir(folder):
            os.mkdir(folder)

        data_file = \
            os.path.join(folder,
                         'UT330_data_{0}.csv'.format(time_str))

        df.to_csv(data_file, index=False)

        self.status.text = "Wrote data to file {0}.".format(data_file)
Callback method for Write to disk
Callback method for Write to disk
Callback method for Write to disk
def callback_write_to_disk(self):
        df = pd.DataFrame(self.controller.device_data)
        if df.empty:
            self.status.text = ("Can't write data to UT330B because "
                                "there's no data to write.")
            return
        df['Timestamp'] = pd.to_datetime(df['Timestamp'])
        time_str = df['Timestamp'].max().strftime("%Y%m%d_%H%M%S")
        dir_path = os.path.dirname(os.path.realpath(__file__))
        dir_path = os.path.dirname(dir_path)
        folder = os.path.join(dir_path, 'data')
        if not os.path.isdir(folder):
            os.mkdir(folder)
        data_file = \
            os.path.join(folder,
                         'UT330_data_{0}.csv'.format(time_str))
        df.to_csv(data_file, index=False)
        self.status.text = "Wrote data to file {0}.".format(data_file)
def callback_write_to_disk ( self ) : df = pd . DataFrame ( self . controller . device_data ) if df . empty : self . status . text = ( "Can't write data to UT330B because " "there's no data to write." ) return df [ 'Timestamp' ] = pd . to_datetime ( df [ 'Timestamp' ] ) time_str = df [ 'Timestamp' ] . max ( ) . strftime ( "%Y%m%d_%H%M%S" ) dir_path = os . path . dirname ( os . path . realpath ( __file__ ) ) dir_path = os . path . dirname ( dir_path ) folder = os . path . join ( dir_path , 'data' ) if not os . path . isdir ( folder ) : os . mkdir ( folder ) data_file = os . path . join ( folder , 'UT330_data_{0}.csv' . format ( time_str ) ) df . to_csv ( data_file , index = False ) self . status . text = "Wrote data to file {0}." . format ( data_file )
Callback method for Write to disk
Callback method for Write to disk
"""Callback method for Write to disk""" # Check folder exists, if not, create it        
self