From b588000e589f25c1591c2860c20df8112b53c78d Mon Sep 17 00:00:00 2001 From: Antoine Mayerowitz Date: Thu, 14 Feb 2019 14:09:56 +0100 Subject: [PATCH] Improve MD to JSON algorithm --- Session_3/Python_Exercises-Copy1.ipynb | 86 ++++++++++---------------- Students/students.json | 2 +- Students/students.yaml | 8 +-- 3 files changed, 39 insertions(+), 57 deletions(-) diff --git a/Session_3/Python_Exercises-Copy1.ipynb b/Session_3/Python_Exercises-Copy1.ipynb index 8c02676..94c9c5b 100644 --- a/Session_3/Python_Exercises-Copy1.ipynb +++ b/Session_3/Python_Exercises-Copy1.ipynb @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -69,7 +69,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -103,13 +103,13 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "f = open(\"students.md\", \"rt\")\n", "txt = f.read()\n", - "f.close()\n" + "f.close()" ] }, { @@ -123,7 +123,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -133,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -151,7 +151,7 @@ "''" ] }, - "execution_count": 19, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -162,14 +162,7 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 55, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -190,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -199,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -209,7 +202,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -218,7 +211,7 @@ "{'a': 'b', 'b': 'c'}" ] }, - "execution_count": 36, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -229,7 +222,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -378,14 +371,17 @@ " if not line.strip()==\"\":\n", " print(f'process \"{line}\"')\n", " lhs, rhs = (line[2:].split(\":\"))\n", - " lhs = lhs.strip()\n", " rhs = rhs.strip()\n", - " record[lhs] = rhs" + " lhs = lhs.strip()\n", + " if rhs != \"\":\n", + " record[lhs] = rhs\n", + " else:\n", + " record[lhs] = None" ] }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -396,7 +392,7 @@ " 'last name': 'Dekel',\n", " 'first name': 'Amit',\n", " 'operating system': 'Windows 10',\n", - " 'memory': '',\n", + " 'memory': None,\n", " 'research interest': 'Social networks',\n", " 'expectations': 'write code more efficiently'},\n", " {'identifier': 'Jaimito30',\n", @@ -406,7 +402,7 @@ " 'operating system': 'mac os mojave',\n", " 'memory': '8GB',\n", " 'research interest': 'Macro-finance, dynamic programming',\n", - " 'expectations': ''},\n", + " 'expectations': None},\n", " {'identifier': 'paolosantini',\n", " 'email': 'paolo.santini5@gmail.com',\n", " 'last name': 'Santini',\n", @@ -447,7 +443,7 @@ " 'memory': '8go',\n", " 'research interest': 'topic modelling, text analysis, network analysis, quantitative history of economics',\n", " 'expectations': 'get insights on text analysis in python'},\n", - " {'identifier': '',\n", + " {'identifier': None,\n", " 'email': 'cemozguzel@gmail.com',\n", " 'last name': 'Ozguzel',\n", " 'first name': 'Cem',\n", @@ -497,7 +493,7 @@ " 'expectations': 'network analysis and learn a bit about scrapping'}]" ] }, - "execution_count": 39, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -508,7 +504,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -517,7 +513,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -526,7 +522,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -535,7 +531,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -545,14 +541,7 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 49, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -562,7 +551,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -575,7 +564,7 @@ " 'yaz26',\n", " 'eniloracyloc',\n", " 'gnoblet',\n", - " '',\n", + " None,\n", " 'DavidRhysBernard',\n", " 'thomasszuber',\n", " 'SuperMayo',\n", @@ -583,7 +572,7 @@ " 'SimonBunel']" ] }, - "execution_count": 51, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -594,7 +583,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -602,13 +591,6 @@ "with open(\"students.yaml\", 'wt') as f:\n", " yaml.dump(observations, f)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -627,7 +609,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.1" + "version": "3.7.2" } }, "nbformat": 4, diff --git a/Students/students.json b/Students/students.json index 0f2fb87..5f52a77 100644 --- a/Students/students.json +++ b/Students/students.json @@ -1 +1 @@ -[{"identifier": "amitdekel", "email": "amit.dek@gmail.com", "last name": "Dekel", "first name": "Amit", "operating system": "Windows 10", "memory": "", "research interest": "Social networks", "expectations": "write code more efficiently"}, {"identifier": "Jaimito30", "email": "jaime.leyva@psemail.eu", "last name": "Leyva", "first name": "Jaime", "operating system": "mac os mojave", "memory": "8GB", "research interest": "Macro-finance, dynamic programming", "expectations": ""}, {"identifier": "paolosantini", "email": "paolo.santini5@gmail.com", "last name": "Santini", "first name": "Paolo", "operating system": "Windows", "memory": "8G (I guess)", "research interest": "Inequality, network, choice of collaboration", "expectations": "I expect to learn how to use python to analyse networks and how to use it for my analysis"}, {"identifier": "MartinJgd", "email": "martin.jegard@gmail.com", "last name": "Jegard", "first name": "Martin", "operating system": "Windows 10", "memory": "8 Go", "research interest": "trade & environmental economics", "expectations": "learn to use new programming tools and improve my coding efficiency"}, {"identifier": "yaz26", "email": "yajna.govind@psemail.eu", "last name": "Govind", "first name": "Yajna", "operating system": "macOS X El Capitan", "memory": "4 GB 1600Mhz", "research interest": "Inequality and Income Distribution", "expectations": "Learning webscrapping and text analysis"}, {"identifier": "eniloracyloc", "email": "caroline.coly@psemail.eu", "last name": "Coly", "first name": "Caroline", "operating system": "N/A", "memory": "N/A", "research interest": "Labour economics", "expectations": "scrap text and analyse it"}, {"identifier": "gnoblet", "email": "Guillaume.noblet@univ-paris1.fr", "last name": "noblet", "first name": "guillaume", "operating system": "manjaro", "memory": "8go", "research interest": "topic modelling, text analysis, network analysis, quantitative history of economics", "expectations": "get insights on text analysis in python"}, {"identifier": "", "email": "cemozguzel@gmail.com", "last name": "Ozguzel", "first name": "Cem", "operating system": "IOS", "memory": "8 GB", "research interest": "International Migration, Labor", "expectations": "Get familiar with all of these tools (e.g. Python, Julia etc.), learn more about webscrapping for collecting data."}, {"identifier": "DavidRhysBernard", "email": "david.rhys.bernard@gmail.com", "last name": "Bernard", "first name": "David", "operating system": "Windows 10", "memory": "4gb", "research interest": "Microeconometrics, causal inference, development", "expectations": "More efficient coding, reproducible research"}, {"identifier": "thomasszuber", "email": "thomas.zuber@psemail.eu", "last name": "Zuber", "first name": "Thomas", "operating system": "OSX", "memory": "4 GB", "research interest": "Structural change, labor reallocation, firm dynamics", "expectations": "git/python fluency"}, {"identifier": "SuperMayo", "email": "a.mayerowitz@gmail.com", "last name": "Mayerowitz", "first name": "Antoine", "operating system": "MacOs Mojave", "memory": "8", "research interest": "TBD", "expectations": "Conquer the world"}, {"identifier": "mfranc01", "email": "manon.francois@psemail.eu", "last name": "FRANCOIS", "first name": "Manon", "operating system": "OSX", "memory": "4 Go 1600 MHz DDR3", "research interest": "International Corporate Taxation", "expectations": "increase coding efficiency and learn new techniques"}, {"identifier": "SimonBunel", "email": "simonbunel@gmail.com", "last name": "Bunel", "first name": "Simon", "operating system": "macOS X El Capitan", "memory": "4 GB", "research interest": "Innovation, patents, etc.", "expectations": "network analysis and learn a bit about scrapping"}] \ No newline at end of file +[{"identifier": "amitdekel", "email": "amit.dek@gmail.com", "last name": "Dekel", "first name": "Amit", "operating system": "Windows 10", "memory": null, "research interest": "Social networks", "expectations": "write code more efficiently"}, {"identifier": "Jaimito30", "email": "jaime.leyva@psemail.eu", "last name": "Leyva", "first name": "Jaime", "operating system": "mac os mojave", "memory": "8GB", "research interest": "Macro-finance, dynamic programming", "expectations": null}, {"identifier": "paolosantini", "email": "paolo.santini5@gmail.com", "last name": "Santini", "first name": "Paolo", "operating system": "Windows", "memory": "8G (I guess)", "research interest": "Inequality, network, choice of collaboration", "expectations": "I expect to learn how to use python to analyse networks and how to use it for my analysis"}, {"identifier": "MartinJgd", "email": "martin.jegard@gmail.com", "last name": "Jegard", "first name": "Martin", "operating system": "Windows 10", "memory": "8 Go", "research interest": "trade & environmental economics", "expectations": "learn to use new programming tools and improve my coding efficiency"}, {"identifier": "yaz26", "email": "yajna.govind@psemail.eu", "last name": "Govind", "first name": "Yajna", "operating system": "macOS X El Capitan", "memory": "4 GB 1600Mhz", "research interest": "Inequality and Income Distribution", "expectations": "Learning webscrapping and text analysis"}, {"identifier": "eniloracyloc", "email": "caroline.coly@psemail.eu", "last name": "Coly", "first name": "Caroline", "operating system": "N/A", "memory": "N/A", "research interest": "Labour economics", "expectations": "scrap text and analyse it"}, {"identifier": "gnoblet", "email": "Guillaume.noblet@univ-paris1.fr", "last name": "noblet", "first name": "guillaume", "operating system": "manjaro", "memory": "8go", "research interest": "topic modelling, text analysis, network analysis, quantitative history of economics", "expectations": "get insights on text analysis in python"}, {"identifier": null, "email": "cemozguzel@gmail.com", "last name": "Ozguzel", "first name": "Cem", "operating system": "IOS", "memory": "8 GB", "research interest": "International Migration, Labor", "expectations": "Get familiar with all of these tools (e.g. Python, Julia etc.), learn more about webscrapping for collecting data."}, {"identifier": "DavidRhysBernard", "email": "david.rhys.bernard@gmail.com", "last name": "Bernard", "first name": "David", "operating system": "Windows 10", "memory": "4gb", "research interest": "Microeconometrics, causal inference, development", "expectations": "More efficient coding, reproducible research"}, {"identifier": "thomasszuber", "email": "thomas.zuber@psemail.eu", "last name": "Zuber", "first name": "Thomas", "operating system": "OSX", "memory": "4 GB", "research interest": "Structural change, labor reallocation, firm dynamics", "expectations": "git/python fluency"}, {"identifier": "SuperMayo", "email": "a.mayerowitz@gmail.com", "last name": "Mayerowitz", "first name": "Antoine", "operating system": "MacOs Mojave", "memory": "8", "research interest": "TBD", "expectations": "Conquer the world"}, {"identifier": "mfranc01", "email": "manon.francois@psemail.eu", "last name": "FRANCOIS", "first name": "Manon", "operating system": "OSX", "memory": "4 Go 1600 MHz DDR3", "research interest": "International Corporate Taxation", "expectations": "increase coding efficiency and learn new techniques"}, {"identifier": "SimonBunel", "email": "simonbunel@gmail.com", "last name": "Bunel", "first name": "Simon", "operating system": "macOS X El Capitan", "memory": "4 GB", "research interest": "Innovation, patents, etc.", "expectations": "network analysis and learn a bit about scrapping"}] \ No newline at end of file diff --git a/Students/students.yaml b/Students/students.yaml index 0747031..07c78e2 100644 --- a/Students/students.yaml +++ b/Students/students.yaml @@ -1,7 +1,7 @@ - {email: amit.dek@gmail.com, expectations: write code more efficiently, first name: Amit, - identifier: amitdekel, last name: Dekel, memory: '', operating system: Windows 10, - research interest: Social networks} -- {email: jaime.leyva@psemail.eu, expectations: '', first name: Jaime, identifier: Jaimito30, + identifier: amitdekel, last name: Dekel, memory: null, operating system: Windows + 10, research interest: Social networks} +- {email: jaime.leyva@psemail.eu, expectations: null, first name: Jaime, identifier: Jaimito30, last name: Leyva, memory: 8GB, operating system: mac os mojave, research interest: 'Macro-finance, dynamic programming'} - {email: paolo.santini5@gmail.com, expectations: I expect to learn how to use python @@ -24,7 +24,7 @@ analysis, quantitative history of economics'} - {email: cemozguzel@gmail.com, expectations: 'Get familiar with all of these tools (e.g. Python, Julia etc.), learn more about webscrapping for collecting data.', - first name: Cem, identifier: '', last name: Ozguzel, memory: 8 GB, operating system: IOS, + first name: Cem, identifier: null, last name: Ozguzel, memory: 8 GB, operating system: IOS, research interest: 'International Migration, Labor'} - {email: david.rhys.bernard@gmail.com, expectations: 'More efficient coding, reproducible research', first name: David, identifier: DavidRhysBernard, last name: Bernard,