Ver código fonte

'' にファイルをアップロード

ivis-yoshida 3 anos atrás
pai
commit
1d21cb3d8c

BIN
dmp_export/Data_manegement_plan2.xlsx


+ 1 - 0
dmp_export/dmp_export.ipynb

@@ -0,0 +1 @@
+{"cells":[{"metadata":{},"id":"decimal-estate","cell_type":"markdown","source":"# DMP出力機能\n\n画面上部の「▶| Run」ボタンを押下していくことで、エクセルファイルが出力されます。"},{"metadata":{},"id":"induced-makeup","cell_type":"markdown","source":"##### 1. 次のセルを実行して、表示されたフォームに研究リポジトリのURLを入力してください。\n例) https://gin.g-node.org/ivis-yoshida/sample-dmp"},{"metadata":{"trusted":true},"id":"royal-surprise","cell_type":"code","source":"x = input()","execution_count":null,"outputs":[]},{"metadata":{},"id":"conditional-alarm","cell_type":"markdown","source":"##### 2. 次のセルを実行して、研究リポジトリを当環境にクローンしてください。"},{"metadata":{"trusted":true},"id":"finished-lying","cell_type":"code","source":"!datalad clone \"$x\" ./repository","execution_count":null,"outputs":[]},{"metadata":{},"id":"medieval-brighton","cell_type":"markdown","source":"##### 3. 次のセルを実行して、Excelファイルを出力してください。"},{"metadata":{"trusted":true},"id":"frank-receipt","cell_type":"code","source":"import json\nimport openpyxl\n\nMAPPING = {\n    \"agreementTitle\": (5, 4),\n    \"agreementDate\": (4, 4),\n    \"submitDate\": (3, 12),\n    \"corporateName\": (4, 12),\n    \"researches\": [\n        {\n            \"index\": (9, 2),\n            \"title\": (9, 3),\n            \"description\": (9, 4),\n            \"manager\": (9, 6),\n            \"dataType\": (9, 7),\n            \"releaseLevel\": (9, 8),\n            \"concealReason\": (9, 9),\n            \"concealPeriod\": (9, 10),\n            \"acquirer\": (9, 11),\n            \"acquireMethod\": (9, 12),\n            \"remarks\": (9, 13)\n        }\n    ]\n}\n\nwith open(\"./repository/dmp.json\") as f:\n    dmp = json.load(f)\n\nwb = openpyxl.load_workbook(\"Data_manegement_plan2.xlsx\")\nsheet = wb[\"様式\"]\n\nfor k ,v in dmp.items():\n    if isinstance(v, str):\n        if k in MAPPING:\n            y, x = MAPPING.get(k)\n            cell = sheet.cell(y, x)\n            cell.value = v\n    elif isinstance(v, list):\n        for temp in v:\n            for k2, v2 in temp.items():\n                y, x = MAPPING[k][0][k2]\n                cell = sheet.cell(y, x)\n                cell.value = v2\n\nwb.save(\"output.xlsx\")","execution_count":null,"outputs":[]},{"metadata":{},"id":"finnish-governor","cell_type":"markdown","source":"##### 4. [Excelファイルをダウンロード](output.xlsx) をクリックし、出力されたExcelファイルをダウンロードしてください。"}],"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.7.10","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":5}

+ 6 - 0
environment.yml

@@ -0,0 +1,6 @@
+name: example-environment
+channels:
+  - conda-forge
+dependencies:
+  - datalad
+  - openpyxl