User Tools

Site Tools


While there are a number of QR code generators available onlie there are times where you might want to create your own. For my work with the BarCamp canterbury I suggested putting QR codes on the lanyards with peoples contact details. This should provide a fast and easy way for people to zap other attendees contact details onto their smart phone of choice.

There is no way that I'm going to sit and use a web based encoder, fortunately there had been a few instances of QR codes in blogs and things lately so that made my life easier. Big shout out to OMG Ubuntu who had a perfectly timed article on QR codes: How to create your own QR Codes in Ubuntu (updated)

The Requirement

Since I'm creating something like 75 - 100 personalized QR codes I need this to be automated, and easy for people to give me the details.

The Process

  • To capture the data I was pointed in the direction of Creating forms in google apps,saves me writing a PHP capture page.
  • Export this data to a file I can parse.
  • Run the data from the file into a QRcode generator, in this case qrencode.

Data Capture

I produced a form using google docs with the fields:

  • First Name
  • Last Name
  • E-Mail
  • Telephone No.
  • Date Of Birth
  • Website Address
  • Postal Address
  • Notes

It is (apparently) available under this link.

Filled in the form with some test data.

Data Munging

Within google docs I was able to save the spreadsheet as a CSV file, this I realized would be problematic with people entering details that contained commas! As a result I went for tab separated values.

Then the trick was to extract stufff from the file using awk:

awk '{print "==========\nNEW RECORD\n==========\nName:"$3","$2"\nEMAIL:"$4"\nTEL:"$5"\nDOB:"$6"\nURL:"$7"\nPOST:"$8"\nNOTES:"$9}' FS="\t" BarCampCant2.tsv

This produces the output:

Name:Last Name,First Name
TEL:Telephone No.
DOB:Date Of Birth
URL:Website Address
POST:Postal Address
TEL:12345 123 456
POST:No Post
NOTES:I am testing

Data Encoding

I have chosen to encode using the MeCard format. While you can use vCard in much the same way, I found MeCard more compact.

The application I'm using to generate the codes is: qrencode

First to generate the MeCard strings using awk:

awk '{print "MECARD:""N:"$3","$2";""EMAIL:"$4";""TEL:"$5";""BDAY:"$6";""URL:"$7";""ADR:"$8";""NOTE:"$9";;"}' FS="\t" BarCampCant2.tsv

Then to create a script:

awk '{print "qrencode -s 6 -o qr-code-"$4".png \"""MECARD:""N:"$3","$2";""EMAIL:"$4";""TEL:"$5";""BDAY:"$6";""URL:"$7";""ADR:"$8";""NOTE:"$9";;\""}' FS="\t" BarCampCant2.tsv

Copy the output from that (not including the first line as this has the headers from the spreadsheet (but is good for checking that the right items are going in the right boxes) into a text file (say starting with:


chmod the file so all can execute it: chmod a+x

Execute that script

copy the png files to where they are useful.

linux/scripts/encode_qr_codes.txt · Last modified: 2011/10/17 12:38 by amon