SHARE
TWEET

bulkan

a guest Nov 24th, 2007 522 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class export:
  2.     def GET(self):
  3.         i = web.input()
  4.  
  5.  
  6.         users = web.select('users', vars=locals())
  7.  
  8.         csv = []
  9.         csv.append("id,name\n")
  10.         for user in users:
  11.             row = []
  12.             row.append(user.id)
  13.             row.append(user.name)
  14.  
  15.             csv.append(",".join(row))
  16.             #writer.writerow(row)
  17.        
  18.         #f.close()
  19.  
  20.         web.header('Content-Type','text/csv')
  21.         web.header('Content-disposition', 'attachment; filename=export.csv')
  22.         print "".join(csv)
  23.         return
RAW Paste Data
Top