mosty init は、Excel ファイルの各シートについて、学生証番号の列、氏名の列、学生の行の範囲を推定し、設定ファイルに書き出します。
🚀 使い方#
mosty init grades.xlsxgrades.xlsx と同じディレクトリに、設定ファイル mosty.grades.xlsx.json5 を書き出します。
Analyze the Excel files and write the config files (pass 1)
Usage: mosty init [OPTIONS] <EXCEL_FILEs>...
Arguments:
<EXCEL_FILEs>... The target Excel files (.xlsx, .xlsm)
Options:
-p, --id-pattern <REGEX> Specify the pattern of student ids [default: ^[0-9]{7}$]
-C, --max-column <INDEX> Specify the last column index (0-origin) to search student ids and names [default: 2]
-o, --output <FILE> Specify the destination of the config file (`-` means stdout)
-f, --force Overwrite the existing config files
-l, --level <LEVEL> Specify the log level [default: warn] [possible values: error, warn, info, debug, trace, off]
-h, --help Print help (see more with '--help')| オプション | 説明 |
|---|---|
-p, --id-pattern | 学生証番号の正規表現(Excel ファイルの前提)。 |
-C, --max-column | 学生証番号と氏名を探す最後の列。0 始まりの番号で、既定の 2 は A〜C 列を意味します。D 列まで探すなら 3 です。 |
-o, --output | 設定ファイルの書き出し先。- を指定すると標準出力に出します。Excel ファイルを 1 つだけ指定したときに使えます。 |
-f, --force | 設定ファイルがすでにあるときに上書きします。指定しないと、上書きせずにエラーになります。 |
複数の Excel ファイルを指定すると、それぞれの設定ファイルを書き出します。
🔍 推定のしかた#
シートごとに、次のように推定します。
- 学生証番号の列: 探す範囲の列のうち、学生証番号に一致するセルが最も多い列。
- 氏名の列: 学生の行で、数値でも学生証番号でもない文字列が最も多い列。学生証番号の左右どちらでも構いません。
- 学生の行の範囲: 学生証番号が現れる最初の行から最後の行まで。
学生証番号が 1 つも見つからないシートは、学生のシートではない(skip: true)とします。
👀 設定ファイルを確認する#
推定は間違えることがあります。mosty check の前に、書き出された設定ファイルを必ず確認してください。
// Generated by `mosty init` from grades.xlsx.
// Review the estimated layouts, and fix them if they are wrong.
// All row and column indices are 0-origin (e.g., column 0 is A, row 0 is Excel row 1).
{
id_pattern: "^[0-9]{7}$",
sheets: {
"課題": {
id_column: 0, // A (student ids: 120)
name_column: 1, // B (names: 120)
start_row: 3, // Excel row 4
end_row: 122, // Excel row 123
},
"配点": { skip: true }, // no student ids found
},
}コメントに、推定の根拠(見つかった学生証番号・氏名の数、Excel での行番号)が書かれています。特に次の点を確認してください。
- 学生の数が、実際の受講者数と合っているか。
- 開始行と終了行が、表の最初と最後の学生を指しているか。
- 学生のシートが
skip: trueになっていないか。逆に、学生のシートでないものが含まれていないか。 CHECK:と書かれた行がないか。学生証番号の数が同じ列が複数あり、左の列を選んだことを表しています。
推定が誤っていれば、設定ファイルを直接書き直してください。書式は 設定ファイル を参照してください。
⚠️ 推定のときに出る警告#
| 警告 | 意味 |
|---|---|
columns A, C have the same number of student ids; chose A | 学生証番号の数が同じ列が複数ある。選ばれた列が正しいか確認する。 |
duplicated student id ... at ... | 同じシートに同じ学生証番号が複数ある。 |
the student id cannot be resolved ... | 学生証番号の数式の計算結果が保存されていない。Excel で開いて保存し直す。 |