Difference between revisions of "Tutorial: Python & DOCX II"
(Created page with "~~~~ ---- =The Basic Idea= <br /> * 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,...") |
(→The CSV File) |
||
Line 11: | Line 11: | ||
=The CSV File= | =The CSV File= | ||
<br /> | <br /> | ||
− | Here is an example csv file. Update to match your needs. | + | 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. |
<br /> | <br /> | ||
:students.csv | :students.csv | ||
Line 20: | Line 20: | ||
Duck, Duffy,U. of Orlando,Disney World,,"Orlando, FL",12345,USA,+1(234)567 89 99,duffyduck@disney.com,Animation I,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 | ||
</source> | </source> | ||
+ | <br /> | ||
+ | =The MS Word template= | ||
+ | <br /> | ||
+ | * 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] | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | |||
+ | |||
+ | [[Category:Python]][[Category:Word]][[Category:docx]] |
Revision as of 04:17, 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.
- [[Media:100_diploma_TEMPLATE.docx|100_diploma_TEMPLATE.docx]