initial step at handling iView db
"metadata": {},
"outputs": [],
"source": [
- "import pymedphys\n",
- "import pymedphys._utilities.filesystem"
+ "import dbfread\n",
+ "\n",
+ "import pymedphys"
]
},
{
"metadata": {},
"outputs": [],
"source": [
- "database_filepaths"
+ "database_a = [path for path in database_filepaths if 'iViewDB_version_a' in str(path)]\n",
+ "database_b = [path for path in database_filepaths if 'iViewDB_version_b' in str(path)]\n",
+ "database_a"
]
},
{
"metadata": {},
"outputs": [],
"source": [
- "with pymedphys._utilities.filesystem.open_no_lock(filepath, \"r\") as a_file:\n",
- " data = a_file.read()"
+ "table_paths = [path for path in database_a if path.suffix == '.DBF']\n",
+ "table_paths"
]
},
{
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "database = {}\n",
+ "\n",
+ "for table_path in table_paths:\n",
+ " key = table_path.stem.lower()\n",
+ " dbf = dbfread.DBF(table_path)\n",
+ " dbf.load()\n",
+ " \n",
+ " database[key] = dbf\n",
+ " "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "database"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "table_ids = {\n",
+ " key: [record['DBID'] for record in records]\n",
+ " for key, records in database.items()\n",
+ "}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "database.items()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "image_paths = [path for path in database_a if path.suffix == '.jpg']\n",
+ "image_ids = [int(path.stem, 16) for path in image_paths]\n",
+ "image_ids"
+ ]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
- "# database_filepaths"
+ "i = 0\n",
+ "\n",
+ "\n",
+ "database['frame'].records.index(image_ids[i])"
]
},
{
"metadata": {},
"outputs": [],
"source": [
- "open?"
+ "database['frame'].records"
]
}
],
