Overview

I had the opportunity to convert tabular information into a vertical writing format in Microsoft Word, so this is a memo.

Before conversion

Research TitleProject NumberDirect Cost
Development of Digital Archive System Construction Methods Considering Sustainability and Usability21K180142600000

After conversion

This uses specified templates and the “Kanjize” library for mutual conversion between numbers and Kanji numerals.

Creating Microsoft Word Files with python-docx

First, create a Microsoft Word template file as follows. While using the specified layout, place {<variable_name>} in the parts where values should be changed.

Then, create a JSON file with values corresponding to the variable names used in the template above.

{}""""""""dipppprrineerreerdrriosseiiinjeecrooceaateddicrr_c__ptccctesa_hho_ntln__scda_uctto"rimai"s:tnbtt:t"veel"":erge":s"o""t:r:"iyg""""a:,t""oK",",r,":""",, ","

Then, by running the following Python script, you can create a Microsoft Word file based on the specified format.

iii}dfodmmtootfppoppecreotaacoomxrert.rr""""""""=ptxahstt=dipppprraktit.aineerreedr=eaft=vdj{rdrriossoayr=eeoseiiinjeecpgtx"(cocrooceaaxiaieattooxnteddicrr.nrntreup_c__ptccDagx=tactesa_hhod.i=etpto_ntln__cottt.tuhscda_uctucee"ret)to"rimaim.xm{iex."s:tnbttept:"nptd:t"veelna+lo"":ergetrktac":s"o"(aeecx"t:r:"gyxe""iytr+t(g"""ea":t"a:mp}a,tph"r""oK"lsg,",ra:e,"tt:e,.""di",ot,ce xm"[")k,ey])"

Number to Kanji Numeral Conversion

When creating the above input JSON file, it was necessary to convert numbers to Kanji numerals.

Example: 2600000 -> 二百六十万

For this conversion, the following library was used.

https://github.com/nagataaaas/Kanjize

By running the following, data managed as numbers can be converted to Kanji numerals.

fprroimntk(ainnjti2zkeanijmip(o2r6t00i0n0t02)k)anji

Summary

We hope this is helpful when creating Microsoft Word files.