I want to generate the following line(s)
1 & {\QPCSymbols\XeTeXglyph 2} & \textarabic{الحمدلله} & \texttt{!} & \verb$\XeTeXglyph 2$ \\
\hline
Let's say the first number is n
and the second one is n+1
, the contents of \textarabic
is obtained from f_nusoos
and the contents of \texttt
from f_keys
. Both files have the same number of lines.
I've created a Python3 script that should get me what I want but I end up with new line symbols (\n
).
Here is what I have so far,
#! python3
import linecache
f_nusoos = 'symbol_nass_list.txt'
f_keys = 'symbol_key_list.txt'
contentfile = open('content.tex', 'w+', encoding="utf-8")
theLine = " "
for x in range(3):
contentfile.write('{} & {{\QPCSymbols\XeTeXglyph {}}} & \\textarabic{{{}}} & \\texttt{{{}}} & \\verb$\XeTeXglyph {}$ \\\\'.format(x+1, x+2,linecache.getline(f_nusoos, x+1).rstrip('\n'), linecache.getline(f_keys, x+1), x+2).rstrip('\n'))
contentfile.write('\hline')
The contents of content.tex
after execution is,
1 & {\QPCSymbols\XeTeXglyph 2} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{!
} & \verb$\XeTeXglyph 2$ \\\hline2 & {\QPCSymbols\XeTeXglyph 3} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{"
} & \verb$\XeTeXglyph 3$ \\\hline3 & {\QPCSymbols\XeTeXglyph 4} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{#
} & \verb$\XeTeXglyph 4$ \\\hline
My expectation, however,
1 & {\QPCSymbols\XeTeXglyph 2} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{!} & \verb$\XeTeXglyph 2$\\
\hline
2 & {\QPCSymbols\XeTeXglyph 3} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{"} & \verb$\XeTeXglyph 3$\\
\hline
3 & {\QPCSymbols\XeTeXglyph 4} & \textarabic{بسم الله الرحمن الرحيم} & \texttt{#} & \verb$\XeTeXglyph 4$\\
\hline
The problem seems to be a new line being inserted after texttt{CONTENT
. I don't know why this is.
Content of f_nusoos.txt
:
بسم الله الرحمن الرحيم
بسم الله الرحمن الرحيم
بسم الله الرحمن الرحيم
Content of f_keys.txt
:
!
"
#