{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "874e645e",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "import pyscisci.all as pyscisci\n",
    "\n",
    "import os\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pylab as plt\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "122e3e61",
   "metadata": {},
   "outputs": [],
   "source": [
    "# set this path to where the OpenAlex database will be stored\n",
    "path2openalex = '/home/ajgates/OpenAlex'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "61b2080c",
   "metadata": {},
   "outputs": [],
   "source": [
    "myoa = pyscisci.OpenAlex(path2openalex, database_extension='csv.gz', keep_in_memory=False) \n",
    "# set keep_in_memory=False if you want to load the database each time its needed - good for when you \n",
    "# cant keep more than one dataframe in memory at a time\n",
    "# otherwise keep_in_memory=True will keep each database in memory after its loaded"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3c15092c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#df_features_to_keep = ['all']  # keep all data\n",
    "# OR\n",
    "df_features_to_keep = ['affiliations', 'authors', 'publications', 'references', \n",
    "                       'publicationauthoraffiliation', 'fields']  # keep everything besides the abstracts\n",
    "myoa.download_from_source(rewrite_existing = False,\n",
    "                         dataframe_list=df_features_to_keep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6395510f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# before we can start running our analysis, we have to preprocess the raw data into\n",
    "# DataFrames that are more convinent to work with\n",
    "\n",
    "# we only need to run this for the first time, but it will take awhile\n",
    "myoa.preprocess(dataframe_list=['all'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "20165e51",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
