ReportLab Flowable for RML Templates

I’ve been side-tracked by a project to generate fairly complex multi-thousand page reports. Python and ReportLab are my go-to standards for this type of project.

I needed to create a plugin for the ReportLab RML templating language to render dynamic Matplotlib charts.

[Read More]

A Mad Dash Through Elixir Types

Elixir for Programmers, Second Edition

Notes

  1. ?≠ returns a codepoint: 8800.

  2. Dividing two integers returns a float. Use div and trunc to get integer results.

  3. In Elixir, nil is false.

  4. Regular expressions are based on PCRE (Perl lives on!).

  5. =~ performs a regular expression match

    iex> str = "once upon a time"
    iex> str =~ ~r/u..n/
    true

  6. =~ also accepts a string as its right hand argument, in which case it returns true if the left string contains the right.

  7. Lists are not arrays. You cannot calculate an offset to a specific element.

  8. map[:missingKey] returns nil. map.missingKey raises an exception.

[Read More]

Always be Normalizing

Elixir for Programmers, Second Edition

I ran into the UTF-8 normalization issue when playing around with the String.split exercises.

Some non-ASCII values can be represented by either one or two graphemes. For example ô can be a single grapheme or composed of two graphemes, o and ^. Always working with normalized UTF-8 strings avoids confusion.

There are four types of UTF normalization which you can read about on the Unicode.org site. Elixir seems to prefer the Canonical Decomposition (NFD) form as that is what the String.equivalent? function uses.

The following examples demonstrate:

[Read More]

String Splitting and Trimming

Elixir for Programmers, Second Edition

I had some confusion with the String.split function in yesterday’s exercises. The documentation says that the trim: true option removes empty strings from the resulting list.

The important term here is “empty”, not “blank” or “whitespace”. My Python-brain was still thinking of trim (or strip) options meaning whitespace is stripped from start/end of the source string.

For example:

[Read More]

Notes on Our First Project

Elixir for Programmers, Second Edition

Setting up the dictionary project as an actual separate Elixir project is a more structured approach than I’ve seen so far. Use of multiple projects has been previously discussed but examples to date have been more at the module level within a project. Excited to see this approach introduced so early in the course. Already changing my assumptions about future project construction.

Also new to me was the use of @ to run a function at compile time. I have used @ notation, but only to declare a fixed value. Not sure when I would use a dynamic compile-time value vs. a configuration, but good to know it exists.

[Read More]

Elixir for Programmers, Second Edition

Sticking with Dave Thomas for the moment and starting the Elixir for Programmers, Second Edition course. I’m expecting that much of this will be a refresher on what I’ve already covered, along with a first foray into Phoenix LiveView.

The LiveView will be a bit outdated given the recent major LiveView improvements, but mostly I’m looking for solid Elixir coding exercises.

I have a first project in mind, which does not require LiveView. Plan to start the project after I finish this course.

[Read More]

Back to Elixir

I’m ready to get back to Elixir after spending the last few weeks using Python and ReportLab/RML to generate multi-thousand line PDF reports. The project is only about 2/3 finished and currently stalled waiting for client answers.

While coding the Python project I kept trying to think about how I’d approach the work in Elixir (assuming a ReportLab-style package was available). In order to create a ReportLab/RML report, I first create a (fairly large) blob of data containing information loaded from multiple .csv files and then arranged and summarized multiple ways.

In Python I use multiple classes (a base class contains many attributes that are themselves classes). Historically, I’d tend to use dictionaries instead of classes, but I also used an IDE (VS Code) for the first time and wanted to get the IDE hints as well as type hint everything.

In Elixir:

[Read More]

A Short Python Break

and some Elixir reading for homework

A short break while I return to the land of Python and ReportLab PDF generation. This is my first time using the commercial ReportLab PLUS markup language (RML). Already have about 1,500 lines of RML generating multi-hundred page reports.

I’ll be doing some reading homework with the early release version of Elixir in Action, Third Edition by Saša Jurić.

Plan to be back in April.

[Read More]