2016-01-27

iPhone note 建身記錄轉成 dokuwiki 表格(3)

iPhone note 建身記錄轉成 dokuwiki 表格(3)

2016-01-27

awk 排版格式沒對齊, 大概這樣
|  01-26 午 -----     |    |     |
|  H8     | 70k/12/3s   | wide pulldown   |
|  AB7    | 55/12/3s    | torso rotation  |
|  PC2b   | 55/15/3s    | rear delt/pec fly  |
|  PC2    | 90/15/3s    | rear delt/pec fly  |
|  lh1    | 50k/15/3s   | glute  |
原始格式
Subject: 01-26 午 -----::
Subject: H8:70k/12/3s:wide pulldown
Subject: AB7:55/12/3s:torso rotation
Subject: PC2b:55/15/3s:rear delt/pec fly
Subject: PC2:90/15/3s:rear delt/pec fly
Subject: lh1:50k/15/3s:glute
用 perl 程式, 排版改成固定欄寬比較好看..
| 01-26 午 -----       |||
| H8   | 70k/12/3s       | wide pulldown            |
| AB7  | 55/12/3s        | torso rotation           |
| PC2b | 55/15/3s        | rear delt/pec fly        |
| PC2  | 90/15/3s        | rear delt/pec fly        |
| lh1  | 50k/15/3s       | glute                    |

排版固定欄寬步驟 :
  1. 自動上傳到 GMail :
    • iPhone : 設定 -> 郵件、聯絡資訊、行事曆 ->加入帳號
  2. 登入 GMail 封存 note ( 請參看 Google E-Mail 封存 ) : 只封存 note 標籤就好了
  3. 下載封存檔 : 我是選 .tgz 壓縮檔
  4. 在 linux command 下, 解開 .mbox 壓縮檔 (年月日T時分秒Z.tgz) :
     tar zxf ~/Downloads/takeout-201ymmddThhmmssZ.tgz 
  5. 檢查 Notes.mbox :
     mutt -f Takeout/\?\?\?\?\?\?/Notes.mbox 
    mutt 內容
    q:離開 d:刪除 u:反刪除 s:儲存 m:信件 r:回覆 g:群組 ?:求助
    1 Jan 26 曾 ( 1) H8:70k/12/3s:wide pulldown
    2 Jan 26 曾 ( 1) AB7:55/12/3s:torso rotation
    3 Jan 26 曾 ( 1) PC2b:55/15/3s:rear delt/pec fly
    4 Jan 26 曾 ( 1) PC2:90/15/3s:rear delt/pec fly
    5 Jan 26 曾 ( 1) lh1:50k/15/3s:glute
    6 Jan 26 曾 ( 1) 01-26 午 -----::
    
  6. 將 Subject 轉成 txt, 並轉換檔案格式 -> Unix/Linux
    ( perl 程式參考 玩具 烏托邦備份/清空 gmail,以及命令列查詢/切割 mbox 格式檔案 :
    perl ~/pl/mail/get-mail-header.perl Subject < 
      Takeout/\?\?\?\?\?\?/Notes.mbox |
      tr -d \\015\\032 > 2016mmdd_note_org
    
  7. 排成 dokuwiki 表格固定欄寬格式
    perl mail2wiki.pl 2016mmdd_note_org >
     2016mmdd_note
    
  8. 排序
  9. 最後格式文件
    | 01-26 午 -----       |||
    | H8   | 70k/12/3s       | wide pulldown            |
    | AB7  | 55/12/3s        | torso rotation           |
    | PC2b | 55/15/3s        | rear delt/pec fly        |
    | PC2  | 90/15/3s        | rear delt/pec fly        |
    | lh1  | 50k/15/3s       | glute                    |
    
  10. 打開 Dokuwiki, 貼上內容
  • perl 程式 mail2wiki.pl
#!/usr/bin/perl

# PRG : mail2wiki.pl
# iPhone note 建身記錄轉成 dokuwiki 表格
# iPhone note -> Gmail -> tgz -> dokuwiki file

# V 1.0.0  2016-01-24

my $argv_no = $#ARGV;

if ($argv_no < 0) {
  print("argv is less than 1.\n");
  die("Usage: ./$0  2016mmdd_note_org\n");
}

my $mail_file = $ARGV[0];  ## mail file
unless (-e $mail_file) { print 找不到檔案:$!; };

open(read_file, $mail_file) || die("$0 : Cannot open Mail File : $mail_file.\n");

while(my $record = )
{
  chomp $record;

  ($sSubject, $sNo, $sRepSet, $sExName)=split(/:/ , $record);

  if ($sRepSet ne "" ) {
    #  | H7   | 35k/15/3s       |decline press            |
    #  | 1234   123456789112345 | 123456789012345678901234
    printf "|%-5s | %-15s | %-24s |\n", $sNo, $sRepSet, $sExName;
  }
  else {
    printf "|%-20s  |||\n", $sNo;
  }

}

close(read_file);

# input  File : 2016mmdd_note_org
#  Subject: 01-22 下午 ----- ::
#  Subject: H7:35k/15/3s:decline press
#  Subject: PL4:135k/15/3s:super squat 624-face out

# output :
#  | 01-22 下午 -----     |||
#  | H7   | 35k/15/3s       |decline press            |
#  | PL4  | 135k/15/3s      |super squat 624-face out |



沒有留言: