Pyspread – The Spreadsheet with a Python connection

Slashdot it! Delicious Share on Facebook Tweet! Digg!
Paul Tessier, 123RF

Paul Tessier, 123RF

Scales & Cells

You can find plenty of spreadsheets offering a multitude of features. The Python-based Pyspread demonstrates that a sophisticated spreadsheet application can also be newcomer-friendly.

Since the early days of electronic data processing, the spreadsheet application has been a standard tool for everyday office life. The focus of this article, Pyspread [1], is related directly to some of the larger, better-known representatives, such as Gnumeric, KSpread/Calligra Sheets, Calc from Libre- and OpenOffice, and PlanMaker from the commercial SoftMaker Office package.

Pyspread, however, has a unique selling point among this gaggle of competitors: It is uncluttered and manageable for beginners (Figure 1). It includes all the basic mechanisms required for table-based work and performing calculations. It also impresses with the fact that it uses an existing scripting language for formulas and evaluations within the data sheet instead of its own macro language. Pyspread thus follows a similar approach to Calc; however, it is based on the popular Python instead of Scheme.

Figure 1: A classic application: travel expenses with a grand total.

Pyspread, which itself is written in Python, groups a wider choice of language constructs and notations with special importance to spreadsheets. This means that the interpreter can fully process calculation formulas within a reasonable time, and it visualizes the results as values or graphics.

You must explicitly enable the scripting content and cryptographically safeguard it with a GnuPG key. The latter eliminates the risk of unintended execution of Python-based malicious code that may be disguised as a harmless formula in a data sheet.

Publishing and Development Goal

Pyspread is licensed under the GPLv3 and is available in the software archives of all major distributions. If you are not happy with the current stable version, 0.3.3 (Debian  8, Ubuntu 15.10), you can download version 1.0 from the project website or opt for the developer version [2]. Version 0.3 is sufficient for the first steps, as is version 0.4. Version 1.0 only has a couple more buttons, such as for direct PDF export.

Pyspread is quite newcomer-friendly, because of its graphical user interface based on Gnome/GTK. But, when you use it, you will notice that the developers are also catering to the preferences of engineers and the way they think. The team led by Martin Manns is committed to the goal of creating the "most pythonic spreadsheet."

Each cell returns a single Python object that can be referenced by cells. These objects can include Python expressions, strings, integers, floating-point numbers, lists, and matrices. You can dock the NumPy library [3] for vectors and matrixes as well as Matplotlib [4] for graphical representations. And, if you have the skills, you can integrate your own acquired knowledge of Python directly.

Program Structure

The arrangement of the components in Pyspread follows the classic layout for spreadsheets. At the center is the data sheet with individual rows and column. Above that, you'll find a combined menu and toolbar along with an input line. You change the cell contents directly or via the input line.

The individual buttons allow direct access to file operations, text and table cell formatting (font, color, size, background, outline), and rotation and alignment of cell contents. Additionally, you can sort the cells and search and replace, in a non-case-sensitive manner, using regular expressions.

When it comes to exchanging data, Pyspread can export data as comma-separated values (CSV) and – as of version 1.x – SVG and PDF files. It can also import and export the older Microsoft Excel format thanks to the xlrd /xlwt library [5]. Matplotlib is used for displaying charts and for data visualization; image data integration comes courtesy of the wxPython framework library [6].

Figure 1 shows an excerpt from an electronic travel expense book with five columns: Trip for the number of times the distance was traveled, From for the start location, To for the destination, as well as the individual and total distances. Underneath, you can see the grand total of the accumulated kilometers. The bar chart to the right shows the relationships of the distances. If you modify the values in the underlying table cells, Pyspread recomputes the formulas and updates the view in the results cells and the graphics.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content