def import_datafile(self,uri): '''Take a file and try to extract data from it using the lib.readfiles''' path = get_path_from_url(uri) if not os.path.isfile(path): return filename = os.path.split(uri)[1] #There are a lot of things that can go wrong here... R isn't friendly with external files try: (columns, data, rows) = readfiles.readfile(uri) dataframe = rsession.dataframe(data,columns,filename,rownames=rows) self.add_r_object(dataframe,filename) self.set_active_robject(dataframe) except: error("Could not read file: %s" % uri) return
def render_dataframe(self,data,columns=None,name=None,rownames=None): '''Take a numpy matrix and bring it into the Python enviroment, also add it to the r session''' if not columns: columns = dict() #Map the columns to anoymous V1,V2,V3... variables for i in range(data.shape[1]): columns['V%s' % (i+1)] = float if not name: inc = 0 for unmes in self.robjects.keys(): if 'unnamed' in unmes: inc += 1 name = 'unnamed' + str(inc+1) #Set the main title to include the open file name. self.window.set_title(__name__ + ' - ' + name) dataframe = rsession.dataframe(data,columns,label=name,rownames=rownames) self.add_r_object(dataframe,name) self.set_active_robject(dataframe) self.handle_dataview(data,columns,rownames=rownames,editable=True)