From 3c4335fd6db301f7600fd8f3af8ef695b9613df4 Mon Sep 17 00:00:00 2001 From: Elmira Ghorbani Date: Mon, 26 Jun 2023 14:23:55 +0330 Subject: [PATCH] create/check data dir for arxiv's papers (#531) --- ...ll_functions_for_knowledge_retrieval.ipynb | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/examples/How_to_call_functions_for_knowledge_retrieval.ipynb b/examples/How_to_call_functions_for_knowledge_retrieval.ipynb index 2383f135..48125e49 100644 --- a/examples/How_to_call_functions_for_knowledge_retrieval.ipynb +++ b/examples/How_to_call_functions_for_knowledge_retrieval.ipynb @@ -150,6 +150,8 @@ "metadata": {}, "outputs": [], "source": [ + "import os\n", + "\n", "import arxiv\n", "import ast\n", "import concurrent\n", @@ -190,6 +192,25 @@ "id": "2de5d32d", "metadata": {}, "outputs": [], + "source": [ + "directory = './data/papers'\n", + "\n", + "# Check if the directory already exists\n", + "if not os.path.exists(directory):\n", + " # If the directory doesn't exist, create it and any necessary intermediate directories\n", + " os.makedirs(directory)\n", + " print(f\"Directory '{directory}' created successfully.\")\n", + "else:\n", + " # If the directory already exists, print a message indicating it\n", + " print(f\"Directory '{directory}' already exists.\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ae5cb7a1", + "metadata": {}, + "outputs": [], "source": [ "# Set a directory to store downloaded papers\n", "data_dir = os.path.join(os.curdir, \"data\", \"papers\")\n", @@ -197,7 +218,7 @@ "\n", "# Generate a blank dataframe where we can store downloaded files\n", "df = pd.DataFrame(list())\n", - "df.to_csv(paper_dir_filepath)\n" + "df.to_csv(paper_dir_filepath)" ] }, {