Skip to main content

Convert a dataset of individuals' names, photos, and custom attributes into a PDF of “intro cards” that describe each individual.

Project description

logo

CI Status PyPI Latest Release License Documentation

create-intro-cards is a Python package that converts a dataset of individuals' names, photos, and custom attributes into a PDF of “intro cards” that describe each individual—all with a single function call. Each intro card displays a person's name, a photo, and a series of attributes based on custom columns in the dataset.

An example of one page of output in the PDF

The input is a Pandas DataFrame, where rows represent individuals and columns their attributes. Columns containing individuals' first names, last names, and paths to photos are required, but the content (and number) of other columns can be freely customized.

An example of the structure of the input Pandas DataFrame

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

The generated PDF contains all individuals' intro cards, arranged four per page. It's a simple way to transform a dataset of individuals' attributes—collected from sources such as surveys—into a fun, easily shareable visual summary.

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 Ruff, docformatter, Sphinx, and pypdf.

Installation

With Python 3.11+ installed, run:

pip install create-intro-cards

Usage

The entry point of the package 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 each page of the PDF, and a log file indicating the names and photo availability statuses of all individuals who had an intro card created. The entire process typically takes only a few minutes or less, depending on the number of individuals, number of custom attributes, photo sizes, and hardware.

make_pdf also provides a host of 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). Because it processes only a subset of the dataset, it runs significantly faster than make_pdf 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-1.0.3.tar.gz (16.5 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-1.0.3-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: create_intro_cards-1.0.3.tar.gz
  • Upload date:
  • Size: 16.5 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-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7d03acb1b5f369d5892cac7458e311f4d2d4ae5af56700e9aeee5eb0aac93a6e
MD5 f7222c3bb362e25db2142d227b06d53b
BLAKE2b-256 f01cdd5b8c5f6405d0f31806a121aa330ba7c20e0cac106f7fde37eea0aaf613

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for create_intro_cards-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f567d356d744dbea9df021cb54c889fed252ff9d894ce2a76906dc6ae78cfdfa
MD5 6c3b416c35a9d07373e0b583d27a56cc
BLAKE2b-256 3c9c5a0931e45fb96def4223920486ab6ee2fc06127afd2c95c927f0a206d9eb

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