Python utilities for data presentation

2,068 views

Published on

Adrian Klaver

An exploration of various Python projects (PyRTF,ReportLab,xlwt) that help with presenting your data in formats (rtf,pdf,xls) that other people want. I will step through a simple data extraction and conversion process using the above software to create an RTF,PDF and XLS file respectively.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,068
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • This is a test
  • Python utilities for data presentation

    1. 1. Python Data Utilities <ul><ul><li>Adrian Klaver </li></ul></ul>
    2. 2. Python Data Utilities <ul><li>Psycopg2 </li></ul><ul><ul><li>http://initd.org/pub/software/psycopg/ </li></ul></ul><ul><ul><li>Current version 2.0.12 </li></ul></ul><ul><ul><li>Using 2.0.6 </li></ul></ul><ul><ul><li>Set up DictConnection </li></ul></ul><ul><ul><li>.pgpass </li></ul></ul>
    3. 3. Python Data Utilities <ul><li>Data manipulation </li></ul><ul><ul><li>Deal with NULL/None </li></ul></ul><ul><ul><li>Order data by category_desc </li></ul></ul><ul><ul><ul><li>Do availability determination </li></ul></ul></ul><ul><ul><ul><li>Pull in correct description and price </li></ul></ul></ul><ul><ul><li>Create rows </li></ul></ul>
    4. 4. Python Data Utilities <ul><li>RTF (Rich Text Format) </li></ul><ul><ul><li>Program </li></ul></ul><ul><ul><ul><li>PyRTF </li></ul></ul></ul><ul><ul><li>Web site </li></ul></ul><ul><ul><ul><li>http://pyrtf.sourceforge.net/ </li></ul></ul></ul><ul><ul><li>Specifications </li></ul></ul><ul><ul><ul><li>http://www.biblioscape.com/rtf15_spec.htm </li></ul></ul></ul><ul><ul><li>Rewrite of code </li></ul></ul><ul><ul><ul><li>pyrtf-ng </li></ul></ul></ul><ul><ul><ul><li>http://code.google.com/p/pyrtf-ng/ </li></ul></ul></ul><ul><ul><ul><li>SVN only </li></ul></ul></ul>
    5. 5. Python Data Utilities <ul><li>RTF (Rich Text Format) </li></ul><ul><ul><li>Notes </li></ul></ul><ul><ul><ul><li>Default language EnglishAustralian </li></ul></ul></ul><ul><ul><ul><li>Measurements </li></ul></ul></ul><ul><ul><ul><ul><li>Dimensions in twips 1inch = 1440 twips </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Fonts are in ½ points </li></ul></ul></ul></ul><ul><ul><ul><li>Name space </li></ul></ul></ul><ul><ul><ul><ul><li>Conflict with ReportLab </li></ul></ul></ul></ul>
    6. 6. Python Data Utilities <ul><li>RTF (Rich Text Format) </li></ul><ul><ul><li>Layout </li></ul></ul><ul><ul><ul><li>Document </li></ul></ul></ul><ul><ul><ul><ul><li>Section </li></ul></ul></ul></ul><ul><ul><ul><li>Table </li></ul></ul></ul><ul><ul><ul><ul><li>Cell </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Paragraph </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><ul><li>Text </li></ul></ul></ul></ul></ul></ul>
    7. 7. Python Data Utilities <ul><li>XLS </li></ul><ul><ul><li>Program </li></ul></ul><ul><ul><ul><li>Xlwt, xlrd, xlutils </li></ul></ul></ul><ul><ul><li>Web Site </li></ul></ul><ul><ul><ul><li>http://pypi.python.org/pypi/xlwt </li></ul></ul></ul><ul><ul><ul><li>http://pypi.python.org/pypi/xlrd </li></ul></ul></ul><ul><ul><ul><li>http://pypi.python.org/pypi/xlutils </li></ul></ul></ul><ul><ul><li>OpenOffice Excel docs </li></ul></ul><ul><ul><ul><li>http://sc.openoffice.org/excelfileformat.pdf </li></ul></ul></ul><ul><ul><li>Mailing List </li></ul></ul><ul><ul><ul><li>http://groups.google.com.au/group/python-excel </li></ul></ul></ul>
    8. 8. Python Data Utilities <ul><li>XLS </li></ul><ul><ul><li>Note </li></ul></ul><ul><ul><ul><li>Column width </li></ul></ul></ul><ul><ul><ul><ul><li>1/256 of the width of the zero character using default font (first FONT record in the file). </li></ul></ul></ul></ul><ul><ul><li>Layout </li></ul></ul><ul><ul><ul><li>Workbook </li></ul></ul></ul><ul><ul><ul><ul><li>Worksheet </li></ul></ul></ul></ul>
    9. 9. Python Data Utilities <ul><li>PDF </li></ul><ul><ul><li>Program </li></ul></ul><ul><ul><ul><li>ReportLab </li></ul></ul></ul><ul><ul><li>Web site </li></ul></ul><ul><ul><ul><li>http://www.reportlab.org/rl_toolkit.html </li></ul></ul></ul><ul><ul><li>Mailing List </li></ul></ul><ul><ul><ul><li>http://two.pairlist.net/mailman/listinfo/reportlab-users </li></ul></ul></ul>
    10. 10. Python Data Utilities <ul><li>PDF </li></ul><ul><ul><li>NumberedCanvas </li></ul></ul><ul><ul><ul><li>http://code.activestate.com/recipes/546511/ </li></ul></ul></ul><ul><ul><ul><li>Newer version works w/images http://code.activestate.com/recipes/576832/ </li></ul></ul></ul><ul><ul><li>Notes </li></ul></ul><ul><ul><ul><li>Dimensions </li></ul></ul></ul><ul><ul><ul><ul><li>Dimensions in points 1 inch = 72 points. </li></ul></ul></ul></ul><ul><ul><ul><li>Origin </li></ul></ul></ul><ul><ul><ul><ul><li>Bottom left </li></ul></ul></ul></ul><ul><ul><ul><li>Array numbering in tables </li></ul></ul></ul><ul><ul><ul><ul><li>Column,Row </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Top left (0,0) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Bottom right (-1,-1) </li></ul></ul></ul></ul>
    11. 11. Python Data Utilities <ul><li>PDF </li></ul><ul><ul><li>Paragraph </li></ul></ul><ul><ul><ul><li>Use para.Paragraph to deal with & <> issues </li></ul></ul></ul><ul><ul><ul><ul><li>from reportlab.platypus import para </li></ul></ul></ul></ul>

    ×