Esempio n. 1
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.file_dialog = FileDialog(dir='~', filters=['*.csv'],
                                   size_hint=(0.8, 0.8))
     # This binds two properties together
     self.file_dialog.bind(file_chosen=self.setter('file_chosen'))
     self.tainted = True
     self.tainted_msg = 'File not chosen in block {}!'.format(self.title)
Esempio n. 2
0
class CSVInBlock(Block):
    out_1 = ObjectProperty()
    file_chosen = StringProperty()
    file_dialog = ObjectProperty()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.file_dialog = FileDialog(dir='~', filters=['*.csv'],
                                      size_hint=(0.8, 0.8))
        # This binds two properties together
        self.file_dialog.bind(file_chosen=self.setter('file_chosen'))
        self.tainted = True
        self.tainted_msg = 'File not chosen in block {}!'.format(self.title)

    def function(self):
        self.out_1.val = pd.read_csv(self.file_chosen, header=0)

    def on_file_chosen(self, instance, value):
        self.tainted = not value.endswith('.csv')
Esempio n. 3
0
class CSVOutBlock(Block):
    in_1 = ObjectProperty()
    path = StringProperty()
    file_dialog = ObjectProperty()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.file_dialog = FileDialog(dir='~', filters=['*.csv'],
                                      size_hint=(0.8, 0.8))
        # Let's bind two together
        self.file_dialog.bind(file_chosen=self.setter('path'))
        self.tainted = True
        self.tainted_msg = 'File not chosen in block {}!'.format(self.title)

    def function(self):
        if type(self.in_1.val) == np.ndarray:
            self.in_1.val = pd.DataFrame(self.in_1.val)
        self.in_1.val.to_csv(path_or_buf=self.path, index=False)

    def on_path(self, instance, value):
        self.tainted = not value.endswith('.csv')