How to let choose the directory to save csv file in python? -


i have function python create simple csv outfile want choose directory of save windows explorer, function :

def exporter():     name_of_file="export"     l = [[1, 2], [2, 3], [4, 5]]     completename = os.path.abspath("c:\temp\%s.csv" % name_of_file)     out = open(completename,"w")     row in l:         column in row:             out.write('%d;' % column)             out.write('\n')         out.close()      qobject.connect(export, signal('clicked()'),exporter) 

export qpushbutton ,thanks !

def exporter(directory='c:\temp\\'):     name_of_file = "export"     l = [[1, 2], [2, 3], [4, 5]]     completename = os.path.abspath("c:/temp/%s.csv" % name_of_file)     full_path = '%(directory)s\%(name_of_file)s.csv' % locals()     out = open(full_path, "w")     row in l:         column in row:             out.write('%d;' % column)             out.write('\n')         out.close()      qobject.connect(export, signal('clicked()'),exporter) 

something trick. pass in path argument.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -