exceltp

Excel third-party extensions


License
MIT
Install
pip install exceltp==0.1.4

Documentation

excellent Python 3

excellent is excel third-party program

  • Read excel file and configuration file.
  • To classify the matched data in setting conditions.
  • Extern integration : notify email, slack, ...

Install

Requirements:

  • python >= 3.5
  • openpyxl : for excel data read(not support xls format)
  • pyYAML : for configuration

pypi

pip3 install exceltp

Usage

Usage: exceltp -c [file] -f [file]

 -c     yaml style configure file.
 -f     xlsx file.
 -V     show version.

Example:
 exceltp -c config.yml -f data.xlsx
 exceltp -V

Warning: not suppport xls format

Configure

analyzer

See sample/sample.yaml file

  • condition in group processed as 'and' logic operation
  • groups processed as 'or' logic operation
  • support date column type
  • date type condition
    • today_equal
    • toay_range_in
    • toay_range_over

action

...

Quick start for Windows OS

Python install

Python 3.5 ์ด์ƒ๋ฒ„์ „์˜ ์„ค์น˜๊ฐ€ ํ•„์š”ํ•˜๋‹ค. https://www.python.org/ ์‚ฌ์ดํŠธ์—์„œ ์„ค์น˜ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›๊ณ  ์„ค์น˜ํ•œ๋‹ค.

์œˆ๋„์šฐ ํ„ฐ๋ฏธ๋„์„ ์‹คํ–‰ํ•˜๊ณ  pip install exceltp ๋˜๋Š” pip3 install exceltp์„ ๋ช…๋ น ๋‚ด๋ ค exceltp๋ฅผ ์„ค์น˜ํ•œ๋‹ค.

Confiuration

์„ค์ • ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ์ˆ˜์ •์‹œ๋…ธํŠธํŒจ๋“œ ๋˜๋Š” ์›Œ๋“œํŒจ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํ•œ๊ธ€ ์ž…๋ ฅ์— ๋Œ€ํ•œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.

UTF-8 ์ธ์ฝ”๋”ฉ์œผ๋กœ ํŒŒ์ผ์„ ์ €์žฅํ•˜๊ฑฐ๋‚˜ NotePad++ ํˆด์„ ์„ค์น˜ํ•ด์„œ ์‚ฌ์šฉํ•œ๋‹ค.

Alt text

config_version: 0.1
analyzer:
    - group_a:
        - test1:
            column_name: f
            column_type: date
            row_startline: 9
            condition: today_equal
            value: -3
    - group_b:
        - test2:
            column_name: f
            column_type: date
            row_startline: 9
            condition: today_equal
            value: -5
action:
    type: email
    email_config:
        subject: Book ๊ตฌ๋งค ํ™•์ธ ๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.
        from: t_account@hotmail.com
        to: to@test.com,to2@test.com
        cc: to3@test.com
        smtp: smtp.live.com:587
        smtp_account: t_account@hotmail.com
        smtp_password : ThisIsPassword
        import_data: [d, e, f]
        msg: |
            ์•ˆ๋…•ํ•˜์„ธ์š”. ์•Œ๋ฆผ๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.
            ์•„๋ž˜ ๋‚ด์šฉ์„ ์ฐธ๊ณ ํ•˜์„ธ์š”.
            $import_data
            ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

condition configure

  • f์—ด์˜ ๋‚ ์งœ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐ๊ฑด์œผ๋กœ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด column_name์˜ ๊ฐ’์„ f๋กœ column_type์„ date๋กœ ์„ค์ •ํ•œ๋‹ค.
  • ์—‘์…€ ์‹œํŠธ์˜ ๋ฐ์ดํ„ฐ ์‹œ์ž‘์ด 9๋ฒˆ์งธ ๋ผ์ธ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— row_startline์„ 9๋กœ ์„ค์ •ํ•œ๋‹ค.
  • f์—ด์˜ ๋‚ ์งœ๋ฐ์ดํ„ฐ ๊ฐ’์„ ๋น„๊ตํ•˜์—ฌ ์˜ค๋Š˜์ด 3์ผ์ „ ๋˜๋Š” 5์ผ์ „์ผ ๋•Œ ์ฐธ์œผ๋กœ ํŒ๋‹จํ•˜๊ธฐ ์œ„ํ•ด 2๊ฐœ์˜ Group์„ ๋“ฑ๋กํ•œ๋‹ค.

action configure

  • ๋ฉ”์ผ ์ „์†ก์— ์‚ฌ์šฉํ•  smtp ์„œ๋ฒ„์ฃผ์†Œ์™€ ๊ณ„์ • ์ •๋ณด๋ฅผ ์ž‘์„ฑํ•œ๋‹ค.
  • subject์™€ msg์— ์ „์†กํ•  ๋ฉ”์ผ์˜ ์ œ๋ชฉ๊ณผ ๋‚ด์šฉ์„ ์ž‘์„ฑํ•œ๋‹ค.
  • msg ๋‚ด์šฉ์— $import_data ํ‚ค์›Œ๋“œ๋ฅผ ํฌํ•จ์‹œํ‚ค๋ฉด ๋ฉ”์ผ ์ „์†ก์‹œ condition์— ์ผ์น˜๋˜๋Š” match data๋กœ ๋ณ€๊ฒฝํ•˜์—ฌ ์ „์†กํ•œ๋‹ค.
  • import_data๋Š” match data ์ค‘์—์„œ ํ•„์š”ํ•œ ์—ด๋งŒ ํฌํ•จ์‹œํ‚ฌ ๊ฒฝ์šฐ ์ž‘์„ฑํ•œ๋‹ค.

Execute

exceltp -c sample/sample.yml -f sample/sample.xlsx
* 'sample/sample.yml' config file
* 'sample/sample.xlsx' excel file
* read config file ...
* prepare analyze and action ...
* validation excel file ...
/usr/local/lib/python3.5/site-packages/openpyxl/reader/worksheet.py:322: UserWarning: Unknown extension is not supported and will be removed
  warn(msg)
* process analyze ...
  process 1/1 sheet name 'MA List'
* do action ...
send: 'mail FROM:<t_account@hotmail.com> size=440\r\n'
reply: b'250 2.1.0 t_account@hotmail.com....Sender OK\r\n'
reply: retcode (250); Msg: b'2.1.0 test@hotmail.com....Sender OK'
.
.
.

Job scheduler

์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋ฐ˜๋ณต์ ์œผ๋กœ ์‹คํ–‰ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์œˆ๋„์šฐ์—์„œ ์ง€์›ํ•˜๋Š” "์ž‘์—… ์Šค์ผ€์ฅด๋Ÿฌ"๋ฅผ ํ™œ์šฉํ•œ๋‹ค.

Alt text

๋ฐฐ์น˜ํŒŒ์ผ์„ ํ•„์š”์— ๋งž๊ฒŒ ์ž‘์„ฑํ•˜๊ณ  ํ•ด๋‹น ํŒŒ์ผ์„ ํ˜ธ์ถœํ•˜๋Š” ์ž‘์—…์„ ๋งŒ๋“ค์–ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•œ๋‹ค.

Alt text