{"id":422,"date":"2021-06-02T22:20:58","date_gmt":"2021-06-02T13:20:58","guid":{"rendered":"https:\/\/mowareblog.net\/3rd\/?p=422"},"modified":"2021-06-03T19:36:26","modified_gmt":"2021-06-03T10:36:26","slug":"%e7%84%a1%e7%b7%9a-02-adif%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e4%bd%9c%e6%88%90","status":"publish","type":"post","link":"https:\/\/mowareblog.net\/3rd\/2021\/06\/422\/%e7%84%a1%e7%b7%9a-02-adif%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e4%bd%9c%e6%88%90\/","title":{"rendered":"[\u7121\u7dda] 02 Python\u3067ADIF\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210 \u524d\u7de8"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">[macOS Catalina 10.15.7]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Excel\u306e\u81ea\u4f5cHAMLOG\u304b\u3089ADIF\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308bPython\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3057\u305f\u3002openpyxl\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u4f7f\u308f\u305apandas\u3067\u51e6\u7406\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u306eADIF\u30d5\u30a1\u30a4\u30eb\u3092eQSL\u306e\u30b5\u30a4\u30c8\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3068\u81ea\u52d5\u7684\u306beQSL\u30ab\u30fc\u30c9\u304c\u4ea4\u4fe1\u76f8\u624b\u3078\u9001\u4ed8\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ea4\u4fe1\u6642\u523b\u306f\u4e16\u754c\u6a19\u6e96\u6642(\uff0d9\u6642\u9593)\u306b\u5909\u63db\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u79fb\u52d5\u5c40\u306e\u5834\u5408\u306f\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u306e\u672b\u5c3e\u306b\u30b9\u30e9\u30c3\u30b7\u30e5\u3068\u30a8\u30ea\u30a2\u756a\u53f7\u3092\u4ed8\u8a18\u3057\u307e\u3059\u304c\u3001\u3053\u306e\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u304c\u30b5\u30a4\u30c8\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u691c\u7d22\u78ba\u8a8d\u3057\u3066\u3001\u306a\u3051\u308c\u3070\u672b\u5c3e\u306a\u3057\u306e\u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u3067eQSL\u30ab\u30fc\u30c9\u3092\u4f5c\u6210\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\u3053\u306e\u5185\u5bb9\u306f\u5f8c\u7de8\u3067\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30c1\u30a7\u30c3\u30af\u3092\u3064\u3051\u305f\u4ea4\u4fe1\u30ed\u30b0\u3092\u62bd\u51fa\u3057\u3066\u4e00\u65e6CSV\u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u307e\u307e\u3067\u3082\u53ef\u80fd\u306a\u306f\u305a\u3067\u3059\u3002\u6a5f\u4f1a\u304c\u3042\u308c\u3070\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5909\u6570time\u3068time\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u30c0\u30d6\u3063\u305f\u306e\u3067\u3001\u5f8c\u8005\u3092tm\u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code>import pandas as pd\nimport csv,os\nimport time as tm\nfrom datetime import datetime, timezone\nfrom selenium import webdriver\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\nfrom selenium.webdriver.common.by import By\n\n# \u81ea\u4f5cHAMLOG\u3092\u8aad\u307f\u8fbc\u3080\ndf = pd.read_excel(&#39;HAMLOG.xlsx&#39;, index_col=0)\nprint(df)\n\n# ADIF\u5217\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u3066\u3044\u308b\u884c\u3092\u62bd\u51fa(ADIF_BL\u304cTRUE(=1))\ndf2 = df[df[&#39;ADIF_BL&#39;] == 1]\n\n# \u62bd\u51fa\u3057\u305f\u884c\u306e0-7\u5217\u76ee\u3092\u53d6\u308a\u51fa\u3059\ndf3 = df2.iloc[:,0:7]\nprint(df3)\n\n# \u4f5c\u6210\u65e5\u6642\u3092\u4ed8\u52a0\u3057\u305fCSV\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u4f5c\u6210\ndatetime_now = datetime.now()\ndatetime_now_str = datetime_now.strftime(&#39;%y%m%d%H%M&#39;)\nfilename = f&quot;\/temp\/{datetime_now_str}_adif_pre.csv&quot;\n\n# \u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092CSV\u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\nwith open(filename, mode=&quot;w&quot;, encoding=&quot;cp932&quot;, errors=&quot;ignore&quot;) as f:\n    df3.to_csv(f ,index=None)\n\n# CSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\nwith open (filename, mode=&quot;r&quot;, encoding=&quot;shift_jis&quot;) as f:\n    reader = csv.reader(f)\n    data_l =[]\n    call_l = []\n    for i,row in enumerate(reader):\n        if i != 0:\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u30b3\u30fc\u30eb\u30b5\u30a4\u30f3\u90e8\u306e\u4f5c\u6210\n            call = f&#39;&lt;CALL:{len(row[0])}&gt;{row[0]}&#39;\n            callsign = row[0]\n            print(callsign)\n            call_l.append(callsign)\n\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u65e5\u4ed8\u3068\u6642\u523b\u306e\u6587\u5b57\u5217\u3092\u7d50\u5408\u3057\u3066\u65e5\u6642\u306b\u3059\u308b\n            dtime = f&#39;{row[1]} {row[2]}&#39;\n            print(dtime)\n\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u65e5\u6642\u306e\u6587\u5b57\u5217\u3092\u6642\u523b\u306b\u5909\u63db\u3059\u308b\n            jst_time = datetime.strptime(dtime, &#39;%Y-%m-%d %H:%M:%S&#39;)\n            print(jst_time)\n\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u6642\u523b\u3092\u4e16\u754c\u6a19\u6e96\u6642\u306b\u5909\u63db\u3057\u3001\u3055\u3089\u306b\u6587\u5b57\u5217\u306b\u5909\u63db\u3059\u308b\n            utc_time = jst_time.astimezone(timezone.utc)\n            utc_str = utc_time.strftime(&#39;%Y%m%d%H%M&#39;)\n\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u4e16\u754c\u6a19\u6e96\u6642\u3092\u65e5\u4ed8\u3068\u6642\u523b\u306b\u5206\u5272\u3057\u3001ADIF\u4ed5\u69d8\u306b\u66f8\u304d\u63db\u3048\u308b\n            date = f&#39;&lt;QSO_DATE:8:D&gt;{utc_str[:8]}&#39;\n            time = f&#39;&lt;TIME_ON:4&gt;{utc_str[8:]}&#39;\n            print(date)\n            print(time)\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u30d0\u30f3\u30c9\u90e8\u306e\u4f5c\u6210\n            band = f&#39;&lt;BAND:{len(row[5])}&gt;{row[5]}&#39;\n            print(band)\n\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u30e2\u30fc\u30c9\u90e8\u306e\u4f5c\u6210\n            mode = f&#39;&lt;MODE:{len(row[6])}&gt;{row[6]}&#39;\n            print(mode)\n\n            # RST\u30ec\u30dd\u30fc\u30c8\u90e8\u306e\u4f5c\u6210\n            his = f&#39;&lt;RST_SENT:{len(row[3])}&gt;{row[3]}&#39;\n            print(his)\n\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u305d\u306e\u4ed6QSL\u95a2\u9023\u7b49\u306e\u90e8\u5206\u3092\u4f5c\u6210\n            etc = &#39;&lt;RST_RCVD:0&gt;&lt;QSL_SENT:1&gt;Y&lt;QSL_SENT_VIA:1&gt;E&lt;QSLMSG:6&gt;CU 73! \\\n&lt;APP_EQSL_AG:1&gt;Y&lt;GRIDSQUARE:4&gt;PM74&lt;EOR&gt;&#39;\n\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u5168\u3066\u306eADIF\u4ed5\u69d8\u3092\u7d50\u5408\u3059\u308b\n            all = call + date + time + band + mode + his + etc\n\n\u3000\u3000\u3000\u3000\u3000\u3000\u3000# \u30c7\u30fc\u30bf\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3059\u308b\n            data_l.append(all)\n\nprint(data_l)\nprint(call_l)\n\n\uff1c\u5f8c\u7de8\u3078\u7d9a\u304f\uff1e<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[macOS Catalina 10.15.7] Excel\u306e\u81ea\u4f5cHAMLOG\u304b\u3089ADIF\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308bPython\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3057\u305f\u3002openpyxl\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u4f7f\u308f\u305apandas\u3067\u51e6\u7406\u3057\u3066\u3044\u307e\u3059\u3002 \u3053\u306eADIF\u30d5 &hellip; <a href=\"https:\/\/mowareblog.net\/3rd\/2021\/06\/422\/%e7%84%a1%e7%b7%9a-02-adif%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e4%bd%9c%e6%88%90\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">[\u7121\u7dda] 02 Python\u3067ADIF\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210 \u524d\u7de8<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-422","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/posts\/422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/comments?post=422"}],"version-history":[{"count":22,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/posts\/422\/revisions"}],"predecessor-version":[{"id":468,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/posts\/422\/revisions\/468"}],"wp:attachment":[{"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/media?parent=422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/categories?post=422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mowareblog.net\/3rd\/wp-json\/wp\/v2\/tags?post=422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}