Difference between revisions of "Tutorial: Python & DOCX II"
(→The MS Word template) |
(→The MS Word template) |
||
Line 24: | Line 24: | ||
<br /> | <br /> | ||
* Here is the MS Word document containing 100 (or whatever number is larger than the number of students) blank diplomas. | * Here is the MS Word document containing 100 (or whatever number is larger than the number of students) blank diplomas. | ||
− | * [[Media:100_diploma_TEMPLATE.docx|100_diploma_TEMPLATE.docx]] | + | * [[Media:100_diploma_TEMPLATE.docx.zip|100_diploma_TEMPLATE.docx]] (this file is zipped. Unzip before using) |
<br /> | <br /> | ||
<br /> | <br /> |
Revision as of 04:19, 28 June 2018
D. Thiebaut (talk) 04:13, 28 June 2018 (EDT)
The Basic Idea
- You have a csv file with a list of students taking different workshops. One field of the csv file contains the first name of the student, another field the last name, and a third field, the workshop title taken by the student.
- The python program shown here generates a Word document where each page is a diploma page, with a logo for the school, the first and last names of the student, and the workshop taken by the student.
- This is a typical Mail-Merge type problem.
- The trick used here is that the MS Word doc diplomas file, containing all the diplomas, starts with 100 (or whatever number is good for you) blank diploma pages, more than the actual number of rows in the csv file, and substitutes the student information in each page.
The CSV File
Here is an example csv file. Update to match your needs. Note that the csv file contains 4 lines, but that some of them might wrap when displayed.
- students.csv
Last name,First name,Institution,Address 1,Address 2,City,zip,Country,Phone,Email,Course,misc1,misc2,misc3 Mouse, Mickey,U. of Orlando,Disney World,,"Orlando, FL",12345,USA,+1(234)567 89 00,mickeymouse@disney.com,Animation I,null,null,null Mouse, Minie,U. of Orlando,Disney World,,"Orlando, FL",12345,USA,+1(234)567 89 00,miniemouse@disney.com,Animation II,null,null,null Duck, Duffy,U. of Orlando,Disney World,,"Orlando, FL",12345,USA,+1(234)567 89 99,duffyduck@disney.com,Animation I,null,null,null
The MS Word template
- Here is the MS Word document containing 100 (or whatever number is larger than the number of students) blank diplomas.
- 100_diploma_TEMPLATE.docx (this file is zipped. Unzip before using)