Skip to main content

A Python module to generate a PDF of intro cards from a dataset of individuals' attributes.

Project description

logo

CI Status PyPI Latest Release License Documentation

create-intro-cards is a Python module that transforms a data set of individuals' names, photos, and custom attributes into a paginated PDF consisting of "intro cards" that describe each individual. Each intro card displays a person's name, their photo, and a series of attributes based on custom columns in the data set.

An example of one page of output in the pdf

The input to the main function — make_pdf — is a Pandas DataFrame, where rows represent individuals and columns their attributes. Columns containing individuals' first names, last names, and paths to their photos are required, but the content (and number) of other columns is arbitrary and completely up to the user.

An example of the structure of the input Pandas DataFrame

These arbitrary columns are used to generate a series of "column name: attribute value" pairings (e.g., "Hometown: New York, NY") for each individual, which is then plotted below their name on their intro card. If an individual doesn't have a value listed for any arbitrary column, that column's "column name: attribute value" pairing will be omitted from their card.

The shareable output PDF contains all individuals' intro cards, four per page. It's a great way for people to get to know each other!

Dependencies

  • NumPy
  • Pandas
  • Matplotlib
  • Pillow
  • ipykernel

For a full list of dependencies—both direct and transitive—please refer to the provided requirements.txt file. The requirements-dev.txt file provides additional dependencies for development — namely Black, docformatter, Sphinx, and pypdf.

Installation

With Python 3.11+, simply run:

pip install create-intro-cards

Usage

The entrypoint of the module is the function make_pdf, which generates a PDF containing intro cards for all the individuals in the input Pandas DataFrame. The function is passed this DataFrame; the names of the columns in the DataFrame that house first names, last names, and paths to individuals' photos; a path to a default photo to use in the event an individual doesn't have a photo path listed; and a path to the directory in which to store the output.

from create_intro_cards import make_pdf
import pandas as pd

people_data = pd.read_csv('path/to/people/data.csv')

make_pdf(people_data, 'First Name', 'Last Name', 'Photo Path', 'path/to/default/photo.png', 'path/to/output/dir')

The output directory will contain the PDF, PNG images of all the PDF's constituent pages, and a logging file that denotes the names and photo availability statuses of all the individuals who had an intro card created.

make_pdf also provides optional keyword arguments to tweak the default layout of the intro cards, from font sizes and text placement to photo boundaries and more.

make_pdf(people_data, 'First Name', 'Last Name', 'Photo Path', 'path/to/default/photo.png', 'path/to/output/dir',
         figure_size=(20, 10), name_x_coord=0.40, desc_font_size=14, photo_axes_bounds=(0.01, 0.02, 0.2, 0.92))

To see how the different keyword arguments affect the appearance of the intro cards, a utility function called make_pdf_preview is provided. This function, which must be run in a Jupyter environment, displays a mock-up of the first page of the PDF that would otherwise be created if make_pdf were run with the same arguments (minus path_to_output_dir). Since it doesn't iterate through the entire data set, it takes a fraction of the time that make_pdf does and is ideal for prototyping.

make_pdf_preview(people_data, 'First Name', 'Last Name', 'Photo Path', 'path/to/default/photo.png', 
                 figure_size=(20, 10), name_x_coord=0.40, desc_font_size=14, photo_axes_bounds=(0.01, 0.02, 0.2, 0.92))

Documentation

For full documentation, please see here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

create_intro_cards-0.2.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

create_intro_cards-0.2.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file create_intro_cards-0.2.0.tar.gz.

File metadata

  • Download URL: create_intro_cards-0.2.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for create_intro_cards-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0baae4fe81e9b4d50f4a549b47dcf0ff778e03cfcec502aaa25b4efaa1980055
MD5 4c263a7b576ebd4c8e99cfb3027a333c
BLAKE2b-256 0cffc0ef47fef4e624d0fb5b65127d7fdba2f84fd90696c10caac7e2560f3c66

See more details on using hashes here.

File details

Details for the file create_intro_cards-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for create_intro_cards-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eeffe5846435f588030e5fe701f5ae3e59a4504c8622608d36cb4f960f76240d
MD5 d03cba583c8a4d24b8dbdb5e5b226190
BLAKE2b-256 a1ab7d1ee4a2366de45542118c0a846e6fe2d6ce5fab97a3043d85722ea24beb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page