Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • fconil-small-programs/python/bases/import-resources-example
1 result
Show changes
Commits on Source (4)
*~
*.pyc
__pycache__
*.py[cod]
__pycache__/
dist/
# Ignore data files
*.csv
......@@ -13,6 +13,84 @@ Packaging informations :
- https://packaging.python.org/en/latest/tutorials/packaging-projects/
- https://choosealicense.com/
## Build and install the package
```shell
$ flit build
$ pip install dist/import_resources_example-0.0.1-py3-none-any.whl
```
WARNING : The package is installed in the virtual environment, so the data
files must be placed there which is not a very pleasant location.
```shell
$ tree .venv/lib/python3.10/site-packages/import_resources_example
├── data
│ └── __init__.py
├── get_oms_data.py
├── get_population_info.py
└── __init__.py
```
When installing the package in development mode with `pip install -e .`, the
data folder is in the clone repository.
## Usage
Install the package and try to execute the functions.
```ipython
In [1]: from import_resources_example import get_population_info
In [2]: get_population_info.extract_population_general_info()
{'AUKUS': {'Time': '1950', 'PopTotal': '206513.782', 'PopDensity': '12.096'},
'African Group': {'Time': '1950',
'PopTotal': '227261.208',
'PopDensity': '7.761'},
'African Union': {'Time': '1950',
'PopTotal': '227274.19',
'PopDensity': '7.692'},
In [3]: from import_resources_example import get_oms_data
In [4]: get_oms_data.get_oms_data()
Out[4]:
[{'TrialID': 'NCT00173563',
'Public-title': 'Induction of Cytokines in Human Monocytes by SARS-CoV in Adults and Children',
'Date-registration': '12/09/2005',
'Source-Register': 'ClinicalTrials.gov',
'Recruitment-Status': 'Recruiting',
'Study type': 'Observational'},
{'TrialID': 'NCT00523276',
'Public-title': 'SARS Survivor Evaluations',
'Date-registration': '30/08/2007',
'Source-Register': 'ClinicalTrials.gov',
'Recruitment-Status': 'Not recruiting',
'Study type': 'Observational'},
```
## Remark
The data files do not need to be packaged, just place them where the data
folder is installed.
WARNING : you have to manually remove the data files copied in the data folder
installed in `site-packages` with pip if you want to remove the package.
```shell
$ pip uninstall import_resources_example
Found existing installation: import_resources_example 0.0.1
Uninstalling import_resources_example-0.0.1:
Would remove:
/home/fconil/Progs/python/imports/resources/.venv/lib/python3.10/site-packages/import_resources_example-0.0.1.dist-info/*
/home/fconil/Progs/python/imports/resources/.venv/lib/python3.10/site-packages/import_resources_example/*
Would not remove (might be manually added):
/home/fconil/Progs/python/imports/resources/.venv/lib/python3.10/site-packages/import_resources_example/data/COVID19-web.27-07-2022.csv
/home/fconil/Progs/python/imports/resources/.venv/lib/python3.10/site-packages/import_resources_example/data/WPP2022_TotalPopulationBySex.csv
Proceed (Y/n)? y
Successfully uninstalled import_resources_example-0.0.1
```
## Troubleshooting
If we have untracked data files in the package tree, flist refuses to build the
......@@ -24,12 +102,13 @@ Fetching list of valid trove classifiers
Untracked or deleted files in the source directory. Commit, undo or ignore these files in your VCS.
```
If we add a line to ignore, e.g. all csv files, in `.gitignore` we get a warning when we want to add one.
If we add a line to ignore, e.g. all csv files, in `.gitignore` we get a
warning when we want to add one.
```shell
$ git add src/import-resources-example/data/WPP2022_TotalPopulationBySex.csv
$ git add WPP2022_TotalPopulationBySex.csv
Les chemins suivants sont ignorés par un de vos fichiers .gitignore :
src/import-resources-example/data/WPP2022_TotalPopulationBySex.csv
src/import_resources_example/data/WPP2022_TotalPopulationBySex.csv
astuce: Utilisez -f si vous voulez vraiment les ajouter.
astuce: Éliminez ce message en lançant
astuce: "git config advice.addIgnoredFile false"
......@@ -37,3 +116,7 @@ astuce: "git config advice.addIgnoredFile false"
As we can append the data files with `-f`, I will ignore the data file in `.gitignore`.
```shell
$ git add -f WPP2022_TotalPopulationBySex.csv
$
```
SortOrder,LocID,Notes,ISO3_code,ISO2_code,SDMX_code,LocTypeID,LocTypeName,ParentID,Location,VarID,Variant,Time,MidPeriod,PopMale,PopFemale,PopTotal,PopDensity
,98502,,,,,,,,ESCWA: Gulf Cooperation Council (GCC),2,Medium,2076,2076.5,44194.054,37123.151,81317.205,31.76
,98300,,,,,,,,ECLAC: United Nations Economic Commission for Latin America and the Caribbean - All countries,6,Instant replacement,2064,2064.5,410753.295,421804.662,832557.957,41.107
161.0,208,16,DNK,DK,208.0,4.0,Country/Area,924.0,Denmark,2,Medium,2057,2057.5,3273.006,3263.523,6536.529,154.185
31.0,262,,DJI,DJ,262.0,4.0,Country/Area,910.0,Djibouti,2,Medium,1998,1998.5,345.318,349.602,694.92,29.979
4.0,1833,,,,747.0,12.0,SDG region,1828.0,Northern Africa and Western Asia,4,Low,2052,2052.5,363538.057,353912.941,717450.998,57.495
141.0,634,,QAT,QA,634.0,4.0,Country/Area,922.0,Qatar,2,Medium,1955,1955.5,14.313,14.354,28.668,2.474
91.0,935,,,,142.0,2.0,Geographic region,1840.0,Asia,3,High,2074,2074.5,3173574.797,3125127.443,6298702.24,200.829
243.0,32,,ARG,AR,32.0,4.0,Country/Area,931.0,Argentina,10,Momentum,2062,2062.5,26136.267,26897.895,53034.162,18.996
122.0,458,9,MYS,MY,458.0,4.0,Country/Area,920.0,Malaysia,7,Zero migration,2098,2098.5,17411.11,17090.822,34501.933,105.013
159.0,804,15,UKR,UA,804.0,4.0,Country/Area,923.0,Ukraine,7,Zero migration,2065,2065.5,14677.116,16269.552,30946.668,53.419
,98423,,,,,,,,ESCAP: Europe (Europe),3,High,2098,2098.5,332181.425,332545.406,664726.831,116.291
42.0,690,,SYC,SC,690.0,4.0,Country/Area,910.0,Seychelles,207,Lower 95 PI,2090,2090.5,37.245,42.183,79.226,173.361
224.0,652,2,BLM,BL,652.0,4.0,Country/Area,915.0,Saint Barthélemy,3,High,2045,2045.5,5.729,5.43,11.159,507.25
137.0,400,,JOR,JO,400.0,4.0,Country/Area,922.0,Jordan,4,Low,2049,2049.5,6963.959,6707.307,13671.266,153.966
,1552,,,,,,,,New EU member states (joined since 2004),6,Instant replacement,2051,2051.5,50247.115,51653.331,101900.447,91.363
147.0,887,,YEM,YE,887.0,4.0,Country/Area,922.0,Yemen,10,Momentum,2058,2058.5,23743.993,24411.127,48155.12,91.208
263.0,909,,,,9.0,2.0,Geographic region,1840.0,Oceania,5,Constant fertility,2070,2070.5,34681.412,34563.132,69244.545,8.157
,1825,,,,,,,,Eastern European Group,2,Medium,2027,2027.5,156328.218,174547.67,330875.888,17.711
,98419,,,,,,,,ESCAP: South-East Asia (SEA),7,Zero migration,2085,2085.5,392638.164,396910.216,789548.38,177.418
190.0,688,24,SRB,RS,688.0,4.0,Country/Area,925.0,Serbia,4,Low,2046,2046.5,2725.575,2901.06,5626.636,73.325
210.0,535,28,BES,BQ,535.0,4.0,Country/Area,915.0,"Bonaire, Sint Eustatius and Saba",5,Constant fertility,2088,2088.5,14.258,14.367,28.624,87.268
,1586,,,,,,,,UNICEF Programme Regions: East Asia and Pacific (EAPRO),7,Zero migration,2041,2041.5,1104290.247,1089770.351,2194060.598,135.103
,1551,,,,,,,,European Union (EU: 27),10,Momentum,2083,2083.5,189587.652,191680.928,381268.579,95.176
222.0,500,19,MSR,MS,500.0,4.0,Country/Area,915.0,Montserrat,6,Instant replacement,2083,2083.5,2.03,1.999,4.029,39.121
,98402,,,,,,,,ESCAP: ADB Group A (ADB_DMC_A),3,High,2031,2031.5,97091.689,98591.252,195682.941,85.776
108.0,4,,AFG,AF,4.0,4.0,Country/Area,5501.0,Afghanistan,207,Lower 95 PI,2031,2031.5,24007.292,23700.67,47719.929,73.495
86.0,566,,NGA,NG,566.0,4.0,Country/Area,914.0,Nigeria,207,Lower 95 PI,2073,2073.5,152268.43,153486.602,307057.44,337.14
231.0,796,19,TCA,TC,796.0,4.0,Country/Area,915.0,Turks and Caicos Islands,6,Instant replacement,2027,2027.5,24.236,24.084,48.321,50.864
,2074,,,,,,,,Commonwealth of Nations,9,No change,2078,2078.5,2388782.484,2385340.109,4774122.593,159.201
34.0,404,,KEN,KE,404.0,4.0,Country/Area,910.0,Kenya,202,Median PI,2075,2075.5,51023.02,53683.41,104706.431,180.302
62.0,434,,LBY,LY,434.0,4.0,Country/Area,912.0,Libya,204,Lower 80 PI,2078,2078.5,3702.868,3789.578,7488.931,4.468
,98437,,,,,,,,ESCAP: WB Upper Middle Income Economies,2,Medium,1977,1977.5,606193.042,599786.999,1205980.04,38.96
173.0,752,,SWE,SE,752.0,4.0,Country/Area,924.0,Sweden,206,Upper 95 PI,2026,2026.5,5482.407,5384.788,10865.053,26.673
251.0,328,,GUY,GY,328.0,4.0,Country/Area,931.0,Guyana,203,Upper 80 PI,2078,2078.5,496.214,464.812,961.478,4.884
154.0,616,,POL,PL,616.0,4.0,Country/Area,923.0,Poland,203,Upper 80 PI,2033,2033.5,18856.896,20060.879,38909.814,127.076
43.0,706,,SOM,SO,706.0,4.0,Country/Area,910.0,Somalia,3,High,2092,2092.5,40760.715,41531.734,82292.45,131.177
24.0,1500,j,,,911.0,13.0,Income group,1802.0,Low-income countries,202,Median PI,2086,2086.5,1031237.413,1062323.155,2093560.568,142.536
,1525,,,,,,,,BRIC,7,Zero migration,2061,2061.5,1654534.73,1623515.116,3278049.846,87.867
199.0,442,,LUX,LU,442.0,4.0,Country/Area,926.0,Luxembourg,207,Lower 95 PI,2071,2071.5,359.048,364.37,724.277,279.644
167.0,372,,IRL,IE,372.0,4.0,Country/Area,924.0,Ireland,202,Median PI,2075,2075.5,2888.068,2876.276,5764.344,84.315
141.0,634,,QAT,QA,634.0,4.0,Country/Area,922.0,Qatar,3,High,2089,2089.5,3004.338,2105.838,5110.176,441.065
,2093,,,,,,,,"SIDS Atlantic, Indian Ocean and South China Sea (AIS)",16,Instant replacement zero migration,2067,2067.5,10262.487,10080.279,20342.765,47.33
,2037,,,,,,,,UNICEF Regions: Middle East and North Africa,16,Instant replacement zero migration,2071,2071.5,353619.855,349167.62,702787.475,63.219
82.0,430,,LBR,LR,430.0,4.0,Country/Area,914.0,Liberia,3,High,2099,2099.5,9276.71,9480.467,18757.178,194.738
8.0,1835,,,,543.0,12.0,SDG region,1828.0,Oceania (excluding Australia and New Zealand),204,Lower 80 PI,2093,2093.5,9088.428,9396.241,18483.177,34.132
54.0,178,,COG,CG,178.0,4.0,Country/Area,911.0,Congo,206,Upper 95 PI,2067,2067.5,8927.899,8966.828,17912.978,52.454
7.0,1830,,,,419.0,12.0,SDG region,1828.0,Latin America and the Caribbean,3,High,2092,2092.5,470663.81,473942.742,944606.552,46.611
203.0,904,,,,419.0,2.0,Geographic region,1840.0,Latin America and the Caribbean,204,Lower 80 PI,2068,2068.5,345269.488,358746.387,704904.202,34.783
218.0,312,2,GLP,GP,312.0,4.0,Country/Area,915.0,Guadeloupe,9,No change,2090,2090.5,157.939,179.046,336.985,206.993
187.0,807,,MKD,MK,807.0,4.0,Country/Area,925.0,North Macedonia,203,Upper 80 PI,2026,2026.5,1044.211,1050.623,2094.699,84.081
157.0,643,,RUS,RU,643.0,4.0,Country/Area,923.0,Russian Federation,202,Median PI,2095,2095.5,55612.811,57817.179,113429.989,6.927
41.0,646,,RWA,RW,646.0,4.0,Country/Area,910.0,Rwanda,2,Medium,2014,2014.5,5524.552,5843.9,11368.451,469.577
228.0,670,,VCT,VC,670.0,4.0,Country/Area,915.0,Saint Vincent and the Grenadines,8,Constant mortality,2036,2036.5,49.465,49.824,99.288,254.586
,1613,,,,,,,,UNFPA: Latin America and the Caribbean (LAC),10,Momentum,2067,2067.5,379130.899,396725.835,775856.735,38.486
59.0,912,,,,15.0,3.0,Subregion,903.0,Northern Africa,6,Instant replacement,2076,2076.5,189327.344,190492.628,379819.971,49.416
,1615,,,,,,,,Non-Self-Governing Territories,9,No change,2100,2100.5,1219.422,1164.799,2384.221,7.863
158.0,703,,SVK,SK,703.0,4.0,Country/Area,923.0,Slovakia,207,Lower 95 PI,2089,2089.5,1571.463,1620.62,3194.051,65.141
276.0,584,,MHL,MH,584.0,4.0,Country/Area,954.0,Marshall Islands,202,Median PI,2089,2089.5,26.09,26.577,52.667,292.594
267.0,928,,,,54.0,3.0,Subregion,909.0,Melanesia,9,No change,2038,2038.5,8257.058,8006.076,16263.135,30.662
222.0,500,19,MSR,MS,500.0,4.0,Country/Area,915.0,Montserrat,9,No change,2079,2079.5,1.341,1.36,2.701,26.223
68.0,72,,BWA,BW,72.0,4.0,Country/Area,913.0,Botswana,4,Low,2100,2100.5,1335.111,1428.685,2763.796,4.877
,2081,,,,,,,,African Union: Eastern Africa,5,Constant fertility,2040,2040.5,332750.437,334815.745,667566.182,104.674
102.0,158,8,TWN,TW,158.0,4.0,Country/Area,906.0,"China, Taiwan Province of China",203,Upper 80 PI,2038,2038.5,11934.576,12387.311,24310.548,686.545
13.0,902,e,,,515.0,5.0,Development group,1803.0,Less developed regions,203,Upper 80 PI,2088,2088.5,5070703.979,5101211.005,10175587.215,125.092
279.0,580,29,MNP,MP,580.0,4.0,Country/Area,954.0,Northern Mariana Islands,204,Lower 80 PI,2076,2076.5,20.932,18.858,39.735,86.947
59.0,912,,,,15.0,3.0,Subregion,903.0,Northern Africa,4,Low,2086,2086.5,175594.656,178390.625,353985.281,46.055
125.0,702,,SGP,SG,702.0,4.0,Country/Area,920.0,Singapore,8,Constant mortality,2083,2083.5,2523.307,2577.544,5100.851,7468.303
,1540,,,,,,,,Economic Community of West African States (ECOWAS),8,Constant mortality,2060,2060.5,418755.731,412672.068,831427.799,165.211
174.0,826,21,GBR,GB,826.0,4.0,Country/Area,924.0,United Kingdom,6,Instant replacement,2062,2062.5,40694.484,40342.699,81037.183,333.842
,1559,,,,,,,,"League of Arab States (LAS, informal name: Arab League)",16,Instant replacement zero migration,2047,2047.5,308857.233,297599.183,606456.416,46.959
,98102,,,,,,,,ECA: Eastern Africa,7,Zero migration,2050,2050.5,341132.008,345032.436,686164.443,147.994
13.0,902,e,,,515.0,5.0,Development group,1803.0,Less developed regions,5,Constant fertility,2078,2078.5,6246811.62,6237480.957,12484292.577,153.473
33.0,231,,ETH,ET,231.0,4.0,Country/Area,910.0,Ethiopia,2,Medium,2008,2008.5,42458.192,41898.913,84357.105,84.357
276.0,584,,MHL,MH,584.0,4.0,Country/Area,954.0,Marshall Islands,6,Instant replacement,2064,2064.5,26.346,26.198,52.544,291.911
,1858,,,,,,,,CANZUK,10,Momentum,2058,2058.5,70351.371,70718.313,141069.683,8.162
64.0,729,,SDN,SD,729.0,4.0,Country/Area,912.0,Sudan,8,Constant mortality,2055,2055.5,44588.156,44932.196,89520.352,50.718
28.0,910,,,,14.0,3.0,Subregion,903.0,Eastern Africa,206,Upper 95 PI,2041,2041.5,378062.748,383109.479,761305.052,114.439
,98433,,,,,,,,ESCAP: ENEA including Russian Fed (ENEA_RUS),6,Instant replacement,2043,2043.5,934969.218,926485.98,1861455.198,66.172
258.0,60,19,BMU,BM,60.0,4.0,Country/Area,918.0,Bermuda,9,No change,2038,2038.5,28.464,31.05,59.514,1102.111
214.0,531,28,CUW,CW,531.0,4.0,Country/Area,915.0,Curaçao,6,Instant replacement,2043,2043.5,106.388,109.309,215.697,508.719
290.0,876,2,WLF,WF,876.0,4.0,Country/Area,957.0,Wallis and Futuna Islands,9,No change,2038,2038.5,5.246,6.002,11.248,80.339
82.0,430,,LBR,LR,430.0,4.0,Country/Area,914.0,Liberia,2,Medium,1987,1987.5,1180.694,1191.755,2372.449,24.631
239.0,484,,MEX,MX,484.0,4.0,Country/Area,916.0,Mexico,2,Medium,1955,1955.5,15739.859,15712.282,31452.141,16.053
,2084,,,,,,,,African Union: Western Africa,9,No change,2077,2077.5,865848.203,850140.233,1715988.435,340.979
163.0,234,17,FRO,FO,234.0,4.0,Country/Area,924.0,Faroe Islands,203,Upper 80 PI,2068,2068.5,36.787,34.821,71.615,51.708
266.0,554,33,NZL,NZ,554.0,4.0,Country/Area,927.0,New Zealand,4,Low,2080,2080.5,2480.588,2487.044,4967.632,18.753
276.0,584,,MHL,MH,584.0,4.0,Country/Area,954.0,Marshall Islands,9,No change,2080,2080.5,34.179,33.263,67.442,374.678
159.0,804,15,UKR,UA,804.0,4.0,Country/Area,923.0,Ukraine,8,Constant mortality,2080,2080.5,8585.976,10020.799,18606.775,32.118
268.0,242,,FJI,FJ,242.0,4.0,Country/Area,928.0,Fiji,202,Median PI,2050,2050.5,546.444,547.73,1094.173,59.889
,98503,,,,,,,,ESCWA: Mashreq subregion,2,Medium,2062,2062.5,168399.535,167916.661,336316.195,195.722
,1704,,,,,,,,UNFPA: West and Central Africa (WCA),4,Low,2091,2091.5,518212.075,530525.37,1048737.445,116.015
69.0,748,,SWZ,SZ,748.0,4.0,Country/Area,913.0,Eswatini,3,High,2041,2041.5,786.356,812.807,1599.163,92.102
,1111,,,,,,,,United States of America (and dependencies),4,Low,2099,2099.5,140188.973,143065.75,283254.723,30.93
,2098,,,,,,,,Countries with Access to the Sea: Northern America,16,Instant replacement zero migration,2051,2051.5,200727.993,202814.842,403542.834,21.636
,1207,,,,,,,,Asia-Pacific Economic Cooperation (APEC),7,Zero migration,2079,2079.5,1271430.314,1268801.754,2540232.067,41.993
60.0,12,,DZA,DZ,12.0,4.0,Country/Area,912.0,Algeria,2,Medium,1957,1957.5,5423.979,5279.272,10703.251,4.494
,2074,,,,,,,,Commonwealth of Nations,6,Instant replacement,2053,2053.5,1737136.695,1718713.613,3455850.308,115.241
1.0,900,,,,1.0,1.0,World,0.0,World,4,Low,2060,2060.5,4415821.287,4455871.747,8871693.034,68.033
168.0,833,19,IMN,IM,833.0,4.0,Country/Area,924.0,Isle of Man,204,Lower 80 PI,2029,2029.5,41.919,42.867,84.793,148.24
268.0,242,,FJI,FJ,242.0,4.0,Country/Area,928.0,Fiji,203,Upper 80 PI,2078,2078.5,679.998,680.781,1361.347,74.513