Customize Export_csv?

I have a method export a doctype to csv file.
import csv

def export_csv_file():
tests = frappe.db.sql(“”“SELECT ID, Name From tabAccount”“”)
with open(‘/home/utf.csv’,‘w’) as fout:
writer=csv.writer(fout)
writer.writerows([tests.keys()])
for row in zip(*tests.values()):
row=[s.encode(‘utf-8’) for s in row]
writer.writerows([row])

I want to customize frappe.core.page.data_import_tool.exporter.get_template()
I have a SQL query .
Ex: "Select ID, Name from tabAccount "
then, I use frappe.db.sql("Select ID, Name from tabAccount ")
then, Write to file csv .
1213131, jacson
1312133, lead
1213133, jame

can you help me ?

Did you find any solution ?

This should do:

  1. Go to that doctype, click on reports on the sidebar, then click on Report Builder
  2. Pick columns you want in the CSV
  3. Then click on Export in the Menu

Actually the data I have is in html & ajax datatable

Uh okay. You do have a post open already for this so please specify your requirements there and you should be able to get an answer.