BOOTH宛先印刷用CSVから色々な便利なリストを作成してCSVで出力するプログラムです。

Overview

BOOTH注文リスト作成スクリプト

このPythonスクリプトは、BOOTHの「宛名印刷用CSV」から、

  • 未発送の注文
  • 今月の注文
  • 特定期間の注文

を抽出した上で、各注文を商品毎に一覧化したCSVとして出力するスクリプトです。

簡単な使い方

ダウンロード

通常は、Relaseから、booth_order_list.exe をダウンロードして使ってください。

実行

ダウンロードした booth_order_list.exe を宛名印刷用CSVファイルと同じフォルダに置いてください。

その後、宛名印刷用CSVファイルが置いてあるフォルダを開いた状態で、空いているところをShiftキーを押しながら右クリックして、「PowerShellウィンドをここで開く(S)」をクリックします。

青い画面(Powershell)が表示されたら、目的に応じて以下のコマンドを入力して下さい。

  • 未発送の注文のリストが欲しい時(booth_orders_unshipped.csv に出力されます)
    • booth_order_list.exe -f [宛名印刷用CSVファイルのファイル名] -o booth_orders_unshipped.csv -u
  • 今月の注文のリストが欲しい時(booth_orders_current.csv に出力されます)
    • booth_order_list.exe -f [宛名印刷用CSVファイルのファイル名] -o booth_orders_current.csv -c
  • 特定期間の注文のリストが欲しい時(booth_orders_range.csv に出力されます)
    • 例:2021年10月1日 ~ 2021年10月10日まで
    • booth_order_list.exe -f [宛名印刷用CSVファイルのファイル名] -o booth_orders_range.csv -r 2021-10-01 2021-10-10
    • 最後の 2021-10-01 2021-10-10 を、必要な期間に置き換えて入力してください。

何も表示されず、次の入力が出来る状態になったら出力完了です。フォルダを確認して下さい。

出力

出力されたCSVは、以下のような形式で表示されます。

注文番号 注文日時 注文の状態 (商品名A) (商品名B) ......
0123456 2021-10-01 12:10:14 支払済み 0 1 ...
0123476 2021-10-01 12:16:01 支払待ち 1 2 ...

商品名が書かれた列に記載の数字は、その注文で注文された商品の数量です。

このCSVファイルをExcelで開くことで、大量の注文があった際の注文リスト生成や、月ごとの商品毎の注文数の集計などが可能となります。

コマンドのオプションの説明

usage: booth_order_list.exe [-h] -f FILE -o OUTPUT [-u] [-c] [-r RANGE RANGE]

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  BOOTHから出力された宛名印刷用CSVファイルのファイル名(必須)
  -o OUTPUT, --output OUTPUT
                        出力するCSVファイルのファイル名(必須)
  -u, --unshipped       未発送の注文のリストを出力
  -c, --current-month   今月の注文のリストを出力
  -r RANGE RANGE, --range RANGE RANGE
                        指定した期間の注文リストを出力(YYYY-MM-DD YYYY-MM-DDで指定)

ヘルプの表示

  • booth_order_list.exe -h
    • 上に記述したヘルプが表示されます。

リストの出力(標準)

  • booth_order_list.exe -f FILE -o OUTPUT
  • booth_order_list.exe --file FILE --output OUTPUT
    • FILEに指定したBOOTHの宛名印刷用CSVをこのプログラムで商品毎のリストに書き換えてOUTPUTに指定したファイルに出力します。
    • 上の -h オプションを付ける場合以外は -f FILE -o OUTPUTは必ず入力が必要です。

未発送の注文の出力

  • booth_order_list.exe -f FILE -o OUTPUT -u
  • booth_order_list.exe --file FILE --output OUTPUT --unshipped
    • FILEに指定したBOOTHの宛名印刷用CSVに書かれた注文のうち、現在の注文の状況が「支払待ち」か「支払済み」の注文(未発送の注文)だけ取り出し、商品毎のリストに書き換えてOUTPUTに指定したファイルに出力します。
    • 商品数の多い店舗で大量の注文が来たときに、わかりやすい注文リストが欲しい時に重宝します(作成者は当初これが欲しくて作りました)。

今月の注文の出力

  • booth_order_list.exe -f FILE -o OUTPUT -c
  • booth_order_list.exe --file FILE --output OUTPUT --current-month
    • FILEに指定したBOOTHの宛名印刷用CSVに書かれた注文のうち、今月の注文だけ抽出し(発送/未発送問わず)、商品毎のリストに書き換えてOUTPUTに指定したファイルに出力します。
    • 今月どの商品がどのくらい注文されたかリスト化したい際に重宝します。

特定期間の注文の出力

  • booth_order_list.exe -f FILE -o OUTPUT -r START_DATE END_DATE
  • booth_order_list.exe --file FILE --output OUTPUT --range START_DATE END_DATE
    • FILEに指定したBOOTHの宛名印刷用CSVに書かれた注文のうち、START_DATE から END_DATE の間に注文された商品のみ抽出し(発送/未発送問わず)、商品毎のリストに書き換えてOUTPUTに指定したファイルに出力します。
    • START_DATE及びEND_DATEは、"年-月-日"の形式で書きます(例:2021-01-04)
    • 「今月の注文の出力」の発展版です。

注意事項

このスクリプトはPixiv/BOOTH公式及び公認のスクリプトではございません。そのため、Pixiv/BOOTH側の仕様変更により、突然利用できなくなる場合がございます。予めご了承下さい。(その際は是非Issueを立てていただけると幸いです)

このプログラムは個人が作成した物です。このプログラムをダウンロード・実行等した事によって発生する一切の事象について制作者は一切の責任を負いかねます。

詳しい人向けの説明

以下、このスクリプトを使って色々なことをしたい、上級者向けの説明です。

Requirement (Tested environment)

  • Python 3.x
    • tested env
      • ubuntu 18.04 (Python 3.6.9)
      • Windows 10 x64 (Python 3.9.2)
    • cannot run python 2.x
  • Library: Standard library
    • os, csv, argparse, datetime, re

run

This script can run without build.

usage: booth_order_list.py [-h] -f FILE -o OUTPUT [-u] [-c] [-r RANGE RANGE]

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  BOOTHから出力された宛名印刷用CSVファイルのファイル名(必須)
  -o OUTPUT, --output OUTPUT
                        出力するCSVファイルのファイル名(必須)
  -u, --unshipped       未発送の注文のリストを出力
  -c, --current-month   今月の注文のリストを出力
  -r RANGE RANGE, --range RANGE RANGE
                        指定した期間の注文リストを出力(YYYY-MM-DD YYYY-MM-DDで指定)

build

Build using "pyinstaller" in this repository release.

pyinstaller booth_order_list.py --onefile

作成者

  • 作成者: hinananoha
  • 所属: Ureshino Network Service
  • 連絡先: info[@]ureshino.dev / Twitter @hinananoha

License

The source code is licensed MIT.

Comments
  • CSV の行数チェックを見直した

    CSV の行数チェックを見直した

    目的

    行数チェックのロジックを見直した

    詳細

    not data のチェックで CSV ファイルの中身が空なのかをチェックしているが、これはそもそも行数が 15 行に足りていないということの特殊な条件を満たす場合の言い換えにすぎず、結局中身が空であれば仮定している CSV ファイルの構造としては不十分であるというエラーメッセージだけでユーザーにはわかると思われる。 したがって、空判定チェックを削除した。

    opened by moba1 2
  • 必要のないファイルチェックを削除した

    必要のないファイルチェックを削除した

    目的

    二重チェックしてしまってる部分を削除する

    原理

    • openr が指定されている場合はファイルが存在しなければ FileNotFoundError が raise されるため、事前に存在性チェックしている行を削除した。
    • デフォルトでは open にあたえられるモードは 'r' なので、 open に指定する必要はないのでモードは省略した
      • https://docs.python.org/ja/3/library/functions.html#open

    余談...

    スレッドを切ってないのであまり問題にはならないが、たとえばあるスレッド Ta がファイル A を削除し、もう1つ別のスレッド Tb がファイル A の存在性チェックを行ってから open するとすると、 Tb がファイルの存在チェックをした直後にスレッド Ta がファイル A を削除した場合、それに Tb は気付かずに open することとなって例外が発生することになる。 つまり、存在性チェックと open がアトミックな処理になってないので、結局ファイルの open には失敗しってしまうことになる。 これはわかりにくいバグのもとにもなるし、元々開けなければ例外が飛ぶため、ファイルが開けるかをそのままためして駄目ならば例外が飛んでくるというような設計にすると余計な存在性チェックもしなくてよくなる上に、コードの見通しも確保できる。

    参考

    result.txt

    opened by moba1 0
  • editorconfig を追加した

    editorconfig を追加した

    目的

    エディタ毎に設定を変更されるとファイルのスタイルが統一できなくなってしまう。 そこでメジャーなエディタであればサポートされている .editorconfig を追加し、細かいエディタの挙動を統一できるようにする。

    変更

    • 全てのファイル
      • 改行文字を LF に
      • 最終行をエディタ上で改行
      • 行の最終文字がスペースならばこれを削除
      • 文字セットは UTF-8 に
    • python ファイル
      • インデントのスタイルは4文字スペースに統一(pep8 でも 4文字スペースにすることが要求されている)
    • markdown ファイル
      • markdown はドキュメントのため、行の最終文字がスペースであっても意味がある場合があるため、行の最終文字のスペースは削除しないように
      • インデントのスタイルは 2 文字スペースが一般的と思われるので、それに統一
    opened by moba1 0
  • コマンドとして実行するモジュール形式に変更した

    コマンドとして実行するモジュール形式に変更した

    目的

    このファイルをそのままモジュールとして実行されることが期待されていると思われるため、モジュールとして import されたときに処理が走らないように変更を加えるのと、 main 関数を用意してこのスクリプトがモジュールとして import されることは期待されていないことを明示するようにした

    加えた変更

    • main 関数を用意して、モジュールの内容をそちらに移した
    • スタイルをPEP 8 に統一
      • 本来はよろしくないが、インデントがほぼ全ての行に含まれなければならなくなってファイル全体の変更が行われるため、この歳にスタイルを統一してしまっても blame も汚れず問題が少ないと思われる
    • モジュールとして読み込まれても実行されないように最終行に必要な記載を2行追加
    opened by moba1 0
  • 期間を指定する部分を改善した

    期間を指定する部分を改善した

    目的

    期間指定に -c-r という2つのオプションが存在してるのを統一したい

    詳細

    統一するにあたって、 -c-r を同一に扱えるフォーマットが必要となる。 そこで、 -r に JSON を指定できるようにして、これらを切り替えられるようにした。 現在は今月を意味する {"type": "current-month" } とある期間を表す {"type": "period", "begin": "YYYY-mm-dd", "end": "YYYY-mm-dd"} の2つのフォーマットを提供している。 つまり、 type プロパティに指定した種類によって JSON の内容を切り替えることで統一的にかつ柔軟に期間指定ができるようになった。

    period タイプの beginend の指定はオプショナルとしてある。 これによって「2020/12/10 以降」を抽出したり、「2020/10/01」までのデータを抽出できるようになった。

    注意事項

    これを含んだものをリリースする際は、後方互換性がなくなっているので v2.0.0 にバンプさせる必要がある

    opened by moba1 2
Releases(v1.0.0)
Owner
hinananoha
hinananoha
A tiny Python library for writing multi-channel TIFF stacks.

xtiff A tiny Python library for writing multi-channel TIFF stacks. The aim of this library is to provide an easy way to write multi-channel image stac

23 Dec 27, 2022
MetaMove is written in Python3 and aims at easing batch renaming operations based on file meta data.

MetaMove MetaMove is written in Python3 and aims at easing batch renaming operations based on file meta data. MetaMove abuses eval combined with f-str

Jan Philippi 2 Dec 28, 2021
Simple Python File Manager

This script lets you automatically relocate files based on their extensions. Very useful from the downloads folder !

Aimé Risson 22 Dec 27, 2022
This python project contains a class FileProcessor which allows one to grab a file and get some meta data and header information from it

This python project contains a class FileProcessor which allows one to grab a file and get some meta data and header information from it. In the current state, it outputs a PrettyTable to txt file as

Joshua Wren 1 Nov 09, 2021
A python module to parse text files with contains secret variables.

A python module to parse text files with contains secret variables.

0 Dec 05, 2022
A Certificate renaming tool made for IEEE CS SBC, SJCE.

PDF Batch Renamer Made for IEEE CS SBC, SJCE How to use? Before using the python script, ensure that pytesseract, pdf2image, opencv and other supporti

Ashwin Kumar U 2 Nov 14, 2021
A python wrapper for libmagic

python-magic python-magic is a Python interface to the libmagic file type identification library. libmagic identifies file types by checking their hea

Adam Hupp 2.3k Dec 29, 2022
Python file organizer application

Python file organizer application

Pak Maneth 1 Jun 21, 2022
Python codes for the server and client end that facilitates file transfers. (Using AWS EC2 instance as the server)

Server-and-Client-File-Transfer Python codes for the server and client end that facilitates file transfers. I will be using an AWS EC2 instance as the

Amal Farhad Shaji 2 Oct 13, 2021
A simple Python code that takes input from a csv file and makes it into a vcf file.

Contacts-Maker A simple Python code that takes input from a csv file and makes it into a vcf file. Imagine a college or a large community where each y

1 Feb 13, 2022
Two scripts help you to convert csv file to md file by template

Two scripts help you to convert csv file to md file by template. One help you generate multiple md files with different filenames from the first colume of csv file. Another can generate one md file w

2 Oct 15, 2022
A tool for batch processing large fasta files and accompanying metadata table to upload to repositories via API

Fasta Uploader A tool for batch processing large fasta files and accompanying metadata table to repositories via API The python fasta_uploader.py scri

Centre for Infectious Disease and One Health 1 Dec 09, 2021
Small Python script to generate a calendar (.ics) file from SIMASTER courses schedule.

simaster.ics Small Python script to generate a calendar (.ics) file from SIMASTER courses schedule. Usage Getting the events.json file from SIMASTER O

Faiz Jazadi 8 Nov 02, 2022
A bot discord that can create directories, file, rename, move, navigate throw directories etc....

File Manager Discord What is the purpose of this program ? This program is made for a Discord bot. Its purpose is to organize the messages sent in a c

1 Feb 02, 2022
BREP : Binary Search in plaintext and gzip files

BREP : Binary Search in plaintext and gzip files Search large files in O(log n) time using binary search. We support plaintext and Gzipped files. Benc

Arnaud de Saint Meloir 5 Dec 24, 2021
Yadl - it is a simple library for working with both dotenv files and environment variables.

Yadl Yadl - it is a simple library for working with both dotenv files and environment variables. Features Validation of whitespaces. Validation of num

Ivan Kapranov 3 Oct 19, 2021
Creates folders into a directory to categorize files in that directory by file extensions and move all things from sub-directories to current directory.

Categorize and Uncategorize Your Folders Table of Content TL;DR just take me to how to install. What are Extension Categorizer and Folder Dumper Insta

Furkan Baytekin 1 Oct 17, 2021
Vericopy - This Python script provides various usage modes for secure local file copying and hashing.

Vericopy This Python script provides various usage modes for secure local file copying and hashing. Hash data is captured and logged for paths before

15 Nov 05, 2022
Powerful Python library for atomic file writes.

Powerful Python library for atomic file writes.

Markus Unterwaditzer 313 Oct 19, 2022
PyDeleter - delete a specifically formatted file in a directory or delete all other files

PyDeleter If you want to delete a specifically formatted file in a directory or delete all other files, PyDeleter does it for you. How to use? 1- Down

Amirabbas Motamedi 1 Jan 30, 2022