Convert CSV / Excel file to EXCEL file and format as table

Context:

I have a request that runs daily. I would like to send query result data to interested parties, but I need it to be formatted for them as they may not have the skills required to format the data as a table. I have SSRS which is great for presenting data, but I still want the file to be emailed for filtering. I can generate CSV or Excel from a query and automate the output email, but not without formatting the table first in the first place.

Problem:

I have a simple CSV / Excel file from a request.

cust_id,cust_name
1,bishop
2,ripley

      

I want to convert this CSV / Excel output file to a file that is pre-formatted as a sortable, filtered table with headers and automates the process.

Excel screen image

Is this possible from python or other server friendly piece of code? Either CSV -> Excel Formatted or Excel -> Excel Formatted. In this case, both types of startup files are fine.

Limitation:

I cannot install, update, or import packages that are not part of the python libraries.

+3


source to share


1 answer


Python xlsxwriter should have all the required functionality.

Module page here: http://xlsxwriter.readthedocs.io/index.html

An example of table formatting is here http://xlsxwriter.readthedocs.io/tutorial02.html



An example of adding automatic filters here: http://xlsxwriter.readthedocs.io/example_autofilter.html

After reading the updated restrictions (cannot install modules on the server), it is clear that using xlsxwriter without something like Anaconda is no-go. Undefined solution unknown, I don't know of a single module that comes with a standard python installation that does what you need.

+2


source







All Articles