{ "cells": [ { "cell_type": "markdown", "id": "21a19f85", "metadata": {}, "source": [ "Check if person on latest uploaded SPA photo is in Wikidata \n", "\n", "* [this Notebook](https://github.com/salgo60/spa2Commons/blob/main/Notebook/SPALatest.ipynb)\n", "* [Issue 7](https://github.com/salgo60/spa2Commons/issues/7)\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "a79e86d6", "metadata": {}, "outputs": [], "source": [ "import urllib3, json\n", "import pandas as pd \n", "http = urllib3.PoolManager() \n", "urllatest = \"https://portrattarkiv.se/endpoints/latest.php\"\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "44382249", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "http status 200\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
_index_type_id_scoresort_source.FirstName_source.LastName_source.BirthDate_source.BirthYear_source.Path..._source.Facts.OtherText_source.Facts.LinkedPortrait_source.Facts.Sport_source.Facts.Tag_source.Facts.Award_source.Suggestions.Sport_source.Suggestions.Tag_source.Suggestions.Award_source.Facts.CivilStatus_source.Suggestions.CivilStatus
0sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtXANone[1637171207000]CarlSondén1846-03-101846/ ARKIV/--Porträttarkiv/S/so/Sonden/Sondén Car......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
1sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtWwNone[1637169787000]ÅkeSoop1810-04-191810/ ARKIV/--Porträttarkiv/S/So/Soop/Soop Åke 181......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
2sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtWgNone[1637135712000]KarlJohansson1896-05-051896/ ARKIV/--Porträttarkiv/J/jo/johansson/johanss......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
3sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtWQNone[1637045195000]Lissola-MartinPersson1868-03-171868/ ARKIV/--Porträttarkiv/P/pe/persson/Persson L......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
4sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtVwNone[1637009693000]RudolfForsén1890-07-181890/ ARKIV/--Porträttarkiv/F/Fo/Forsen/Forsén Rud......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
..................................................................
95sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtMQNone[1636151969000]KarlSvensson1887-07-271887/ ARKIV/--Porträttarkiv/S/sv/svensson/svensson......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
96sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtMANone[1636151642000]KarlKarlsson1884-07-251884/ ARKIV/--Porträttarkiv/J/jo/johansson/johanss......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
97sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtLwNone[1636151558000]KarlKarlsson1884-07-251884/ ARKIV/--Porträttarkiv/K/ka/karlsson/karlsson......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
98sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtLgNone[1636151311000]CarlJohansson1895-07-021895/ ARKIV/--Porträttarkiv/J/jo/johansson/johanss......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
99sveportrattarkiv6Person4e1scVvZ-EAAAAAAAAAtLQNone[1636150689000]KarlClaeson1885-12-221885/ ARKIV/--Porträttarkiv/C/Cl/Claeson/Claeson K......NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
\n", "

100 rows × 76 columns

\n", "
" ], "text/plain": [ " _index _type _id _score sort \\\n", "0 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtXA None [1637171207000] \n", "1 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtWw None [1637169787000] \n", "2 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtWg None [1637135712000] \n", "3 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtWQ None [1637045195000] \n", "4 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtVw None [1637009693000] \n", ".. ... ... ... ... ... \n", "95 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtMQ None [1636151969000] \n", "96 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtMA None [1636151642000] \n", "97 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtLw None [1636151558000] \n", "98 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtLg None [1636151311000] \n", "99 sveportrattarkiv6 Person 4e1scVvZ-EAAAAAAAAAtLQ None [1636150689000] \n", "\n", " _source.FirstName _source.LastName _source.BirthDate _source.BirthYear \\\n", "0 Carl Sondén 1846-03-10 1846 \n", "1 Åke Soop 1810-04-19 1810 \n", "2 Karl Johansson 1896-05-05 1896 \n", "3 Lissola-Martin Persson 1868-03-17 1868 \n", "4 Rudolf Forsén 1890-07-18 1890 \n", ".. ... ... ... ... \n", "95 Karl Svensson 1887-07-27 1887 \n", "96 Karl Karlsson 1884-07-25 1884 \n", "97 Karl Karlsson 1884-07-25 1884 \n", "98 Carl Johansson 1895-07-02 1895 \n", "99 Karl Claeson 1885-12-22 1885 \n", "\n", " _source.Path ... \\\n", "0 / ARKIV/--Porträttarkiv/S/so/Sonden/Sondén Car... ... \n", "1 / ARKIV/--Porträttarkiv/S/So/Soop/Soop Åke 181... ... \n", "2 / ARKIV/--Porträttarkiv/J/jo/johansson/johanss... ... \n", "3 / ARKIV/--Porträttarkiv/P/pe/persson/Persson L... ... \n", "4 / ARKIV/--Porträttarkiv/F/Fo/Forsen/Forsén Rud... ... \n", ".. ... ... \n", "95 / ARKIV/--Porträttarkiv/S/sv/svensson/svensson... ... \n", "96 / ARKIV/--Porträttarkiv/J/jo/johansson/johanss... ... \n", "97 / ARKIV/--Porträttarkiv/K/ka/karlsson/karlsson... ... \n", "98 / ARKIV/--Porträttarkiv/J/jo/johansson/johanss... ... \n", "99 / ARKIV/--Porträttarkiv/C/Cl/Claeson/Claeson K... ... \n", "\n", " _source.Facts.OtherText _source.Facts.LinkedPortrait _source.Facts.Sport \\\n", "0 NaN NaN NaN \n", "1 NaN NaN NaN \n", "2 NaN NaN NaN \n", "3 NaN NaN NaN \n", "4 NaN NaN NaN \n", ".. ... ... ... \n", "95 NaN NaN NaN \n", "96 NaN NaN NaN \n", "97 NaN NaN NaN \n", "98 NaN NaN NaN \n", "99 NaN NaN NaN \n", "\n", " _source.Facts.Tag _source.Facts.Award _source.Suggestions.Sport \\\n", "0 NaN NaN NaN \n", "1 NaN NaN NaN \n", "2 NaN NaN NaN \n", "3 NaN NaN NaN \n", "4 NaN NaN NaN \n", ".. ... ... ... \n", "95 NaN NaN NaN \n", "96 NaN NaN NaN \n", "97 NaN NaN NaN \n", "98 NaN NaN NaN \n", "99 NaN NaN NaN \n", "\n", " _source.Suggestions.Tag _source.Suggestions.Award \\\n", "0 NaN NaN \n", "1 NaN NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", ".. ... ... \n", "95 NaN NaN \n", "96 NaN NaN \n", "97 NaN NaN \n", "98 NaN NaN \n", "99 NaN NaN \n", "\n", " _source.Facts.CivilStatus _source.Suggestions.CivilStatus \n", "0 NaN NaN \n", "1 NaN NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", ".. ... ... \n", "95 NaN NaN \n", "96 NaN NaN \n", "97 NaN NaN \n", "98 NaN NaN \n", "99 NaN NaN \n", "\n", "[100 rows x 76 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "SPAdetail = \"https://portrattarkiv.se/details/\"\n", "\n", "r = http.request('POST', urllatest,\n", " headers={'Content-Type': 'application/json'})\n", "print(\"http status \", r.status) \n", "data = json.loads(r.data.decode('utf-8'),) \n", "df = pd.json_normalize(data[\"hits\"][\"hits\"])\n", "df" ] }, { "cell_type": "code", "execution_count": 3, "id": "33f05021", "metadata": {}, "outputs": [], "source": [ "# version 1 export to csv and use OpenTRefine\n", "df.to_csv(\"SPA_latest.csv\")" ] }, { "cell_type": "code", "execution_count": null, "id": "b5febcad", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.9.4" } }, "nbformat": 4, "nbformat_minor": 5 }