Generate a series of cards printed front and back with unique QR codes from a CSV dataset. This tool takes a CSV file with geographical coordinates and creates cards with QR codes linking to Google Maps locations.
Active
This tool creates printable cards based on CSV data, with each card containing:
- Project title and description
- Contact information
- Feasibility information
- Opportunities and challenges
- Potential funders
- QR code linking to the geographic location on Google Maps
The workflow:
- Process CSV data to extract project information
- Generate Google Maps links from coordinates
- Create QR codes for each location
- Generate individual markdown cards
- Compile cards into a printable PDF
- Clone this repository:
git clone [repository-url]
cd TOOL_printable_cards_QR_code- Set up a virtual environment (recommended):
# Create and setup virtual environment
./setup.sh
# Activate the virtual environment
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windows- Install required dependencies:
pip install -r requirements.txt- Optional: Install pandoc for PDF generation:
# On macOS
brew install pandoc
# On Ubuntu/Debian
sudo apt-get install pandoc
# On Windows with Chocolatey
choco install pandocRun the main script to generate QR codes and cards:
python main.py --input your_data.csvThis will:
- Generate Google Maps URLs from coordinates
- Create QR codes for each URL
- Generate markdown files for each card
- Attempt to compile a PDF if pandoc is installed
python main.py --input your_data.csv \
--card-template card_template.md \
--output-dir output \
--qr-dir qr_codes \
--zoom 18 \
--use-mapping \
--skip-pdfOptions explained:
--input, -i: Path to the input CSV file--card-template: Path to the card markdown template (default: card_template.md)--output-dir: Directory for all output files (default: output)--qr-dir: Directory for QR code images (default: qr_codes)--zoom: Zoom level for Google Maps URLs (default: 18)--use-mapping: Use header_mapping.json to map CSV headers--skip-pdf: Skip PDF generation step (useful if pandoc is not installed)
The input CSV must contain the following columns:
OBJECTID: Unique identifier for each entryYour Name: Name of the contact personYour Organization: Organization of the contact personDescribe the opportunity: Description of the opportunityIs the opportunity feasible in the next 3 years?: Feasibility of the opportunityWhat do you expect would go smoothly?: Expected smooth aspectsWhat would you expect to be challenging?: Expected challengesWho might be a potential funder of this work?: Potential fundersx: Longitude coordinatey: Latitude coordinate
You can also run individual components separately:
- Create weblinks from coordinates:
python create_weblinks.py input.csv --output links.csv --zoom 18- Generate QR codes:
python qrgen.py "https://www.google.com/maps?q=lat,lon&t=k&z=18" qr_codes/qr.png- Create cards from markdown:
python create_cards.py --cards-dir output/cards --latex-template layout_template.tex --output-pdf output/printable_cards.pdfYou can run the test script to verify that all components are working correctly:
python test.pyThis will test the weblink creation and QR code generation without external dependencies.
TOOL_printable_cards_QR_code/
├── main.py # Main script to run the entire workflow
├── create_weblinks.py # Creates Google Maps links from coordinates
├── qrgen.py # Generates QR codes from URLs
├── create_cards.py # Creates printable cards from markdown files
├── card_template.md # Template for card content
├── layout_template.tex # LaTeX template for PDF layout
├── setup.sh # Script to setup virtual environment
├── test.py # Script to test core functionality
├── qr_codes/ # Directory for generated QR codes
├── output/ # Directory for output files
│ ├── cards/ # Generated card markdown files
│ └── printable_cards.pdf # Final PDF with printable cards
└── requirements.txt # Python dependencies
You can modify the card_template.md file to change the content and layout of the cards. The template uses variables in double curly braces (e.g., {{title}}) that will be replaced with data from the CSV.
Available template variables:
{{title}}: Project title{{contact_person}}: Contact person name{{contact}}: Contact person name (duplicate){{description}}: Project description{{potential_funders}}: Potential funding sources{{funders}}: Potential funding sources (duplicate){{feasibility_next_3_years}}: Feasibility assessment{{feasible_3yr}}: Feasibility assessment (duplicate){{opportunities}}: Expected smooth aspects{{challenges}}: Expected challenging aspects{{qr_code_filename}}: QR code filename{{qr_code}}: QR code file path
The layout_template.tex file controls the final PDF layout. You can customize this file to change the appearance of the printed cards.
The template uses Jinja2 syntax for variables and loops:
{% for card in cards %}...{% endfor %}: Loop through all cards{{ card.title }}: Insert card title- Other variables:
card.contact,card.description,card.funders, etc.
If PDF generation fails or is skipped, there are several options:
-
Check if pandoc is installed:
pandoc --version
If not installed, follow the installation instructions in the Installation section.
-
Check if LaTeX is installed: Pandoc requires a LaTeX distribution to generate PDFs. Install one of these:
- macOS:
brew install --cask mactex-no-guiorbrew install --cask basictex - Ubuntu/Debian:
sudo apt-get install texlive-xetex - Windows: Install MiKTeX or TeX Live
- macOS:
-
Skip PDF generation: If you don't want to install pandoc or LaTeX, use the
--skip-pdfflag:python main.py --input your_data.csv --skip-pdf
-
Generate PDF separately: After running the main script with
--skip-pdf, you can generate PDFs manually:python create_cards.py --cards-dir output/cards --output-pdf output/printable_cards.pdf
-
Alternative PDF generation: You can also use other tools to generate PDFs from the markdown or LaTeX files in the output directory.
If QR code generation fails, ensure that the required libraries are installed:
pip install qrcode[pil] PillowIf the script reports missing headers, you have several options:
-
Modify your CSV file to use the exact header names required by the tool.
-
Use the header mapping feature:
- When the script detects missing headers, it will offer to create a mapping file
- Follow the prompts to map your existing headers to the required ones
- Run the script again with the
--use-mappingflag:
python main.py --input your_data.csv --use-mapping
-
The tool also automatically handles minor differences like trailing spaces or case changes.
Example mapping process:
❌ CSV is missing required headers: Describe the opportunity
Would you like to create a header mapping file to resolve this issue? (y/n)
y
Enter the corresponding header in your CSV for 'Describe the opportunity' (or leave blank to skip):
Describe the opportunity
✅ Header mapping saved to 'header_mapping.json'
Run the script again with the --use-mapping flag to use this mapping
See the LICENSE file for details.
- RTGS Lab