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
gitfs is a FUSE file system that fully integrates with git - Version controlled file system

gitfs is a FUSE file system that fully integrates with git. You can mount a remote repository's branch locally, and any subsequent changes made to the files will be automatically committed to the rem

Presslabs 2.3k Jan 08, 2023
A python script to pull the transactions of an Algorand wallet and put them into a CSV file.

AlgoCSV A python script to pull the transactions of an Algorand wallet and put them into a CSV file. Dependancies: Requests Main features: Groups: Com

21 Jun 25, 2022
Python function to stream unzip all the files in a ZIP archive: without loading the entire ZIP file or any of its files into memory at once

Python function to stream unzip all the files in a ZIP archive: without loading the entire ZIP file or any of its files into memory at once

Department for International Trade 206 Jan 02, 2023
A JupyterLab extension that allows opening files and directories with external desktop applications.

A JupyterLab extension that allows opening files and directories with external desktop applications.

martinRenou 0 Oct 14, 2021
A python script to convert an ucompressed Gnucash XML file to a text file for Ledger and hledger.

README 1 gnucash2ledger gnucash2ledger is a Python script based on the Github Gist by nonducor (nonducor/gcash2ledger.py). This Python script will tak

Thomas Freeman 0 Jan 28, 2022
Kartothek - a Python library to manage large amounts of tabular data in a blob store

Kartothek - a Python library to manage (create, read, update, delete) large amounts of tabular data in a blob store

15 Dec 25, 2022
This is a junk file creator tool which creates junk files in Internal Storage

This is a junk file creator tool which creates junk files in Internal Storage

KiLL3R_xRO 3 Jun 20, 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
BOOTH宛先印刷用CSVから色々な便利なリストを作成してCSVで出力するプログラムです。

BOOTH注文リスト作成スクリプト このPythonスクリプトは、BOOTHの「宛名印刷用CSV」から、 未発送の注文 今月の注文 特定期間の注文 を抽出した上で、各注文を商品毎に一覧化したCSVとして出力するスクリプトです。 簡単な使い方 ダウンロード 通常は、Relaseから、booth_ord

hinananoha 1 Nov 28, 2021
Python file organizer application

Python file organizer application

Pak Maneth 1 Jun 21, 2022
Utils for streaming large files (S3, HDFS, gzip, bz2...)

smart_open — utils for streaming large files in Python What? smart_open is a Python 3 library for efficient streaming of very large files from/to stor

RARE Technologies 2.7k Jan 06, 2023
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
A simple bulk file renamer, written in python.

Python File Editor A simple bulk file renamer, written in python. There are two functions, the bulk rename and the bulk file extention change. Bulk Fi

Sam Bloomfield 2 Dec 22, 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
Various technical documentation, in electronically parseable format

a-pile-of-documentation Various technical documentation, in electronically parseable format. You will need Python 3 to run the scripts and programs in

Jonathan Campbell 2 Nov 20, 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
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
Maltego transforms to pivot between PE files based on their VirusTotal codeblocks

VirusTotal Codeblocks Maltego Transforms Introduction These Maltego transforms allow you to pivot between different PE files based on codeblocks they

Ariel Jungheit 18 Feb 03, 2022
A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir".

the problem What directory should your app use for storing user data? If running on macOS, you should use: ~/Library/Application Support/AppName If

ActiveState Software 948 Dec 31, 2022
Ini adalah program python untuk mengubah background foto dalam 1 folder, tidak perlu satu satu

Myherokuapp my web drive You can see my web drive and can request film/Application do you want in here my blog you can visit my blog RemBg ini adalah

XnuxersXploitXen 13 Dec 01, 2022