Hello, The Zope Book mentions that you can use Perl with Zope - but that's all I've found about Perl usage. I have to convert some database query to an Excel file and the only way I know to do this is the Spreadsheet::WriteExcel module. Thus I would like to write a Perl script using this module but I have no idea how to use Perl at all. Alternatively I would like to do the conversion with Python if this is possible. Kind regards Andreas.
Andreas Tille wrote:
Hello,
The Zope Book mentions that you can use Perl with Zope - but that's all I've found about Perl usage. I have to convert some database query to an Excel file and the only way I know to do this is the
Spreadsheet::WriteExcel
Why not just write the results out as a .csv? You can open them in Excel... cheers, Chris
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Chris Withers Sent: Wednesday, October 09, 2002 3:49 PM To: Andreas Tille Cc: Zope user list Subject: Re: [Zope] Perl scripts
Andreas Tille wrote:
Hello,
The Zope Book mentions that you can use Perl with Zope - but that's all I've found about Perl usage. I have to convert some database query to an Excel file and the only way I know to do this is the
Spreadsheet::WriteExcel
Why not just write the results out as a .csv?
You can open them in Excel...
cheers,
Chris
Yes, this is pretty easy. Some python script to get you going: --------------- rs = some_sql_query() for item in rs: result_str += (str(item.DATE) + ',' + str(item.STUFF) + ',' + str(item.MORESTUFF) + '\n') response.setHeader('Content-type', 'application/vnd.ms-excel') response.setHeader('Content-Length', len(result_str)) response.setHeader('Content-Disposition', 'attachment;filename=filename.csv') return result_str ---------------- Be warned that mozilla doesn't handle this quite right. It launches excel and hands it the data but seems to translate the EOL characters in the process so excel refuses to split the columns. Ironically, Excel 2000 only accepts the unix EOL character for csv data. So: it works fine from IE but not so fine from Mozilla. If anyone has a dual browser solution I'd like to see it. I'm also leaving out the necessary code to escape quotes and quote commas (because I can't seem to find it right now).
On Thu, 10 Oct 2002 9:17 am, Charlie Reiman wrote:
I'm also leaving out the necessary code to escape quotes and quote commas (because I can't seem to find it right now).
"python csv module" in google (feel lucky, it'll get you straight there :) Richard
On Wed, 9 Oct 2002, Charlie Reiman wrote:
Yes, this is pretty easy. Some python script to get you going: --------------- rs = some_sql_query()
for item in rs: result_str += (str(item.DATE) + ',' + str(item.STUFF) + ',' + str(item.MORESTUFF) + '\n')
response.setHeader('Content-type', 'application/vnd.ms-excel') response.setHeader('Content-Length', len(result_str)) response.setHeader('Content-Disposition', 'attachment;filename=filename.csv') return result_str ----------------
Be warned that mozilla doesn't handle this quite right. It launches excel and hands it the data but seems to translate the EOL characters in the process so excel refuses to split the columns. Ironically, Excel 2000 only accepts the unix EOL character for csv data. So: it works fine from IE but not so fine from Mozilla. If anyone has a dual browser solution I'd like to see it. This hins quite helpful - at least I get reasonable effects under Linux with Galeon - this handles the resulting file with Gnumeric as default. (I have not tested it with Excel - because of a lack of a running Excel installation but it seems promissing.)
The only drawback is that I did not found a way to specify sane table headings like "DATE" | "STUFF" | "MORESTUFF" --------------------------------------------- 2002-7-17 | some stuff | some more stuff ... | ... | ... Any way to do this with csv?? Kind regards and thanks for the hint Andreas.
On Thursday 10 October 2002 00:48, Chris Withers wrote:
You can open them in Excel... Excel, IMHO, sucks. ;-) It's even can't open correct CSV when you click on it. Use OpenOffice instead. Then you can generate XML with styles, colors whatever; zip and rename. Here you have pure Excel-like file for the StarCalc.
-- Regards, Bogdan "Our products just aren't engineered for security." -- Brian Valentine, senior vice-president of Windows development ... what exactly are Microsoft products engineered for? The garbage!
On Thu, 10 Oct 2002, Bo M. Maryniuck wrote:
On Thursday 10 October 2002 00:48, Chris Withers wrote:
You can open them in Excel... Excel, IMHO, sucks. ;-) It's even can't open correct CSV when you click on it. Use OpenOffice instead. Then you can generate XML with styles, colors whatever; zip and rename. Here you have pure Excel-like file for the StarCalc. While I'm completely share your opinion in this field I have to face the situation that exactly those target users in mind have no idea that there is any other program than Excel and they are not allowed to change their installation themselves even if I would teach them. I hope that this will change in the future ...
Kind regards Andreas.
On Friday 11 October 2002 09:09, Andreas Tille wrote:
While I'm completely share your opinion in this field I have to face the situation that exactly those target users in mind have no idea that there is any other program than Excel and they are not allowed to change their installation themselves even if I would teach them. I hope that this will change in the future ...
Ah! They probably also don't know what Mozilla is. You can use my Zope-stuff to upgrade theirs skills: http://www.zope.org/Members/Bolid/zfriday ;-) But in my company, where nobody knew (before I came) what OO is, now it is cool tool for various purposes. Since M$ enforses folks use theirs suxxy unsecure products the one of the solutions is to GENTLY enforce users to use OO in this case. How? Easy: provide a StarCalc document as main format with various functions (you can even put some small description, screenshot whatever) and a CSV as additional format. Never, ever expect hackers to be able to read closed proprietary document formats like Microsoft Word. Most hackers react to these about as well as you would to having a pile of steaming pig manure dumped on your doorstep. -- ESR (http://www.tuxedo.org/~esr/faqs/smart-questions.html) -- Regards, Bogdan If vegetarians eat vegetables, what do humanitarians eat?
participants (5)
-
Andreas Tille -
Bo M. Maryniuck -
Charlie Reiman -
Chris Withers -
Richard Jones