
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Pycgettb is convert guided form excel files to text data. No special programming is required.
First, prepare the same xlsx format of the data and the template, to define the text data using the jinja2-based template.
Recommended to use it in virtual environment.
openpyxl <https://openpyxl.readthedocs.io/en/default/>
_Jinja2 <http://jinja.pocoo.org/docs/2.9/>
_Click <http://click.pocoo.org/5/>
_::
# Example, Using Python3 venv module.
$ python3 -m venv env
$ source env/bin/activate
(env)$ pip install pycgettb
::
$ git clone https://github.com/hrsano645/pycgettb.git
$ cd pycgettb
# Example, Using Python3 venv module.
$ python3 -m venv env
$ source env/bin/activate
(env)$ pip install -r requirements.txt
::
(env)$ pycgettbcli --help
Usage: pycgettbcli [OPTIONS] SRC_TEMPLATE SRC_DATA EXPORT_TEMPLATE
Options:
--export_filename TEXT Set export filename
--help Show this message and exit.
--export_filename
: If not specified, create a file named exported_data.txt
.When using pycgettb, prepare three files. The sample file is ./tests/testfiles/
.
Source Data: An xlsx file containing the data.
.. image:: https://github.com/hrsano645/pycgettb/blob/master/docs/img/example_data_img.png?raw=true :alt: source data file image
Source Template: An xlsx file with embedded template variables. Make the same worksheet and cell layout of the source data file.
.. image:: https://github.com/hrsano645/pycgettb/blob/master/docs/img/example_template_img.png?raw=true :alt: source template file image
Export Template: The jinja2 template file (html, json, csv, etc...)
※:The jinja2 template currently supports variables only.
::
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
</head>
<body>
<h1>{{ title }}</h1>
<table>
<tr>
<td>date</td>
<td>name</td>
<td>note</td>
</tr>
<tr>
<td>{{ date_1 }}</td>
<td>{{ name_1 }}</td>
<td>{{ note_1 }}</td>
</tr>
<tr>
<td>{{ date_2 }}</td>
<td>{{ name_2 }}</td>
<td>{{ note_2 }}</td>
</tr>
</table>
</body>
</html>
Template files(source template, export template) must be the same template variable name. Based on that convert to text data using jinja2.
::
(env)$ pycgettbcli ./tests/testfiles/template.xlsx ./tests/testfiles/data.xlsx ./tests/testfiles/export_template.html
Converted result. Default file name is exported_data.txt
::
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Example Title</title>
</head>
<body>
<h1>Example Title</h1>
<table>
<tr>
<td>date</td>
<td>name</td>
<td>note</td>
</tr>
<tr>
<td>2017-01-01 00:00:00</td>
<td>suzuki</td>
<td>日本語テスト</td>
</tr>
<tr>
<td>2017-01-02 00:00:00</td>
<td>sato</td>
<td>None</td>
</tr>
</table>
</body>
</html>
pycgettb can also be used as a library.
::
from pycgettb import Source
from pycgettb import TextRender
# set file path
src_template = "[source template file path]"
src_data = "[source data file path]"
export_template = "[export template file path]"
# define export filename
export_filename = "exported_file.txt"
source = Source(src_template, src_data)
source_data_map = source.parse()
textrender = TextRender(export_template, source_data_map)
# write rendreing textdata
with open(export_filename, "w") as export_file:
export_file.write(textrender.render())
MIT License
FAQs
convert guided form excel to text data by template base
We found that pycgettb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.