Skip to content

Commit

Permalink
Update saveJSON.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvdt committed Nov 13, 2021
1 parent 5dde6b7 commit 0f4037a
Showing 1 changed file with 55 additions and 48 deletions.
103 changes: 55 additions & 48 deletions saveJSON.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,82 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"source": [
"import os\r\n",
"import getdbfields as dlg\r\n",
"from PyQt5 import QtWidgets\r\n",
"import json \r\n",
"\r\n",
"try :\r\n",
" FP = open('FydStore.json', 'r')\r\n",
" store = json.load(FP)\r\n",
" FP.close()\r\n",
"except :\r\n",
" store = {}\r\n",
" \r\n",
"app = QtWidgets.QApplication([]) \r\n",
"print(store)"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'Fields': {'project': 'BAR', 'dataset': 'beep', 'condition': 'Cuprizone', 'subject': 'Top', 'stimulus': 'RFestReverscorr', 'setup': 'Ephys_A1.03', 'investigator': 'Bart', 'date': '2021-09-24', 'logfile': 'beepTop_log', 'version': '1.0'}, 'dirPath': 'I:/Users/togt/Desktop', 'Sessnr': 1}\n"
"output_type": "error",
"ename": "ModuleNotFoundError",
"evalue": "No module named 'mysql'",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_14432/1130177926.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mgetdbfields\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mdlg\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mPyQt5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mQtWidgets\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mjson\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\Users\\chris\\Documents\\herseninstituut\\FYD_Python\\getdbfields.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mre\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[1;31m#import datetime\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mmysql\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnector\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 14\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mPyQt5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mQtWidgets\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mQtCore\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mPyQt5\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mQtWidgets\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mQMessageBox\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'mysql'"
]
}
],
"source": [
"import os\n",
"import getdbfields as dlg\n",
"from PyQt5 import QtWidgets\n",
"import json \n",
"\n",
"try :\n",
" FP = open('FydStore.json', 'r')\n",
" store = json.load(FP)\n",
" FP.close()\n",
"except :\n",
" store = {}\n",
" \n",
"app = QtWidgets.QApplication([]) \n",
"print(store)"
]
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"source": [
"w = dlg.dlgFields(store)\r\n",
"w.show()\r\n",
"w.Reconnect()\r\n",
"app.exec_()\r\n",
"\r\n",
"if w.Ret == 0 : #accepted : btn ok/cancelled\r\n",
" Fields = w.Fields \r\n",
" dir_path = w.dirPath\r\n",
" Sessnr = w.Sessnr\r\n",
" store = { \"Fields\" : Fields, \"dirPath\" : dir_path, \"Sessnr\" : Sessnr } \r\n",
" \r\n",
" FP = open('FydStore.json', 'w')\r\n",
" json.dump(store, FP)\r\n",
" FP.close()\r\n",
" \r\n",
" print(store)"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"name": "stdout",
"text": [
"Adding to table conditions\n"
]
}
],
"source": [
"w = dlg.dlgFields(store)\n",
"w.show()\n",
"w.Reconnect()\n",
"app.exec_()\n",
"\n",
"if w.Ret == 0 : #accepted : btn ok/cancelled\n",
" Fields = w.Fields \n",
" dir_path = w.dirPath\n",
" Sessnr = w.Sessnr\n",
" store = { \"Fields\" : Fields, \"dirPath\" : dir_path, \"Sessnr\" : Sessnr } \n",
" \n",
" FP = open('FydStore.json', 'w')\n",
" json.dump(store, FP)\n",
" FP.close()\n",
" \n",
" print(store)"
]
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"source": [],
"outputs": [],
"source": []
"metadata": {}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
"name": "python3",
"display_name": "Python 3.9.3 64-bit"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -86,9 +90,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.9.3"
},
"interpreter": {
"hash": "57990f1ad2ea89c67ddae7f31d40c478205c5912da0fccfb7c5cfbb2b8bf17ad"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}

0 comments on commit 0f4037a

Please sign in to comment.