PEATDB/Ekin/IO.py
def export_csv(self, data, fitdata=None):
        """Export the current tab to a csv file"""

        import tkFileDialog
        filename=tkFileDialog.asksaveasfilename(defaultextension='.csv',initialdir=self.savedir,
                                              filetypes=[("CSV file","*.csv"),
                                                         ("All files","*.*")],
                                              parent=self.ekin_win)
        if not filename:
            return
        labels = data.labels    
        #labels=data[0]['label'],data[1]['label']        
        x,y = data.getxy()
       
        try:
            import csv
            csvwriter = csv.writer(open(filename, "wb"))
            #csvwriter = csv.writer(sys.stdout)
        except:
            tkMessageBox.showwarning("Save file",
                            "Cannot open this file for writing\n(%s)" % filename)
            return
        csvwriter.writerow(labels)
        for i in range(len(x)):
            csvwriter.writerow([x[i],y[i]])

        # Ask if we should export the fit too
        export_fit=tkMessageBox.askyesno("Export fit",
                                "Export fitted values?",parent=self.ekin_win)
        if export_fit and fitdata != None:
            f=[]
            for i in fitdata.keys():
                f.append(fitdata[i])
            csvwriter.writerow(f)
        return
Export the current tab to a csv file
Export the current tab to a csv file
Export the current tab to a csv file
def export_csv(self, data, fitdata=None):
        import tkFileDialog
        filename=tkFileDialog.asksaveasfilename(defaultextension='.csv',initialdir=self.savedir,
                                              filetypes=[("CSV file","*.csv"),
                                                         ("All files","*.*")],
                                              parent=self.ekin_win)
        if not filename:
            return
        labels = data.labels    
        x,y = data.getxy()
        try:
            import csv
            csvwriter = csv.writer(open(filename, "wb"))
        except:
            tkMessageBox.showwarning("Save file",
                            "Cannot open this file for writing\n(%s)" % filename)
            return
        csvwriter.writerow(labels)
        for i in range(len(x)):
            csvwriter.writerow([x[i],y[i]])
        export_fit=tkMessageBox.askyesno("Export fit",
                                "Export fitted values?",parent=self.ekin_win)
        if export_fit and fitdata != None:
            f=[]
            for i in fitdata.keys():
                f.append(fitdata[i])
            csvwriter.writerow(f)
        return
def export_csv ( self , data , fitdata = None ) : import tkFileDialog filename = tkFileDialog . asksaveasfilename ( defaultextension = '.csv' , initialdir = self . savedir , filetypes = [ ( "CSV file" , "*.csv" ) , ( "All files" , "*.*" ) ] , parent = self . ekin_win ) if not filename : return labels = data . labels x , y = data . getxy ( ) try : import csv csvwriter = csv . writer ( open ( filename , "wb" ) ) except : tkMessageBox . showwarning ( "Save file" , "Cannot open this file for writing\n(%s)" % filename ) return csvwriter . writerow ( labels ) for i in range ( len ( x ) ) : csvwriter . writerow ( [ x [ i ] , y [ i ] ] ) export_fit = tkMessageBox . askyesno ( "Export fit" , "Export fitted values?" , parent = self . ekin_win ) if export_fit and fitdata != None : f = [ ] for i in fitdata . keys ( ) : f . append ( fitdata [ i ] ) csvwriter . writerow ( f ) return
Export the current tab to a csv file
Export the current tab to a csv file
"""Export the current tab to a csv file""" #labels=data[0]['label'],data[1]['label']         #csvwriter = csv.writer(sys.stdout) # Ask if we should export the fit too
self
data
fitdata