MoSPIMicrodata 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: MoSPIMicrodata
3
+ Version: 1.0.0
4
+ Summary: This package can be used to download the data from MoSPI Microdata Portal (https://microdata.gov.in). Kindly call the getDatasets method with First parameter as location to save the data and second Parameter as API key generated from MicroData Portal Profile Section.
5
+ Author: DIID,Ministry of Statistics and Programme Implementation
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: requests
8
+ Dynamic: author
9
+ Dynamic: description
10
+ Dynamic: description-content-type
11
+ Dynamic: requires-dist
12
+ Dynamic: summary
13
+
14
+ \# MoSPI Microdata access
15
+
16
+
17
+
18
+ This package can be used to access the Microdata available from MoSPI microdata Portal (https://microdata.gov.in)
19
+
20
+
21
+
22
+ \# Features
23
+
24
+
25
+
26
+ use the getDatasets("Path to save the Microdata","your API key downloaded from MosPI Microdata Portal") to choose
27
+
28
+ the Dataset to download.
29
+
30
+
31
+
32
+ For example , you will get the option like this on calling the method
33
+
34
+
35
+
36
+ 277:Annual Survey of Industries 2019-20
37
+
38
+ 275:Annual Survey of Industries 2020-21
39
+
40
+ 256:Annual Survey of Industries 2023-24
41
+
42
+ 255:Comprehensive Modular Survey on Education-NSS 80th Round-2025
43
+
44
+ 254:Periodic Labour Force Survey (PLFS), Key Employment Unemployment Indicators for (January 2024 - December 2024)
45
+
46
+ 239:Comprehensive Modular Survey on Telecom-NSS 80th Round-2025
47
+
48
+ 238:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2023-2024
49
+
50
+ 237:Household Consumption Expenditure Survey: 2023-24
51
+
52
+ 236:Time Use Survey (TUS), January 2024-December 2024
53
+
54
+ 230:Urban Frame Survey (UFS) Summary Data
55
+
56
+ 224:Household Consumption Expenditure Survey: 2022-23
57
+
58
+ 223:Time Use Survey (TUS), January 2019-December 2019
59
+
60
+ 222:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2022-2023
61
+
62
+ 221:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2021-2022
63
+
64
+ 220:Comprehensive Annual Modular Survey (CAMS),NSS 79th round: 2022-23
65
+
66
+ Total pages:13,Page:1 of 13,
67
+
68
+ Enter Survey index number(put n to Navigate to Next Page):
69
+
70
+
71
+
72
+ You can choose the Numeric Index no to download the associated datasets
73
+
74
+
75
+
76
+ \## Installation
77
+
78
+
79
+
80
+ pip install package-name
81
+
82
+
83
+
84
+
85
+
@@ -0,0 +1,9 @@
1
+ README.md
2
+ setup.py
3
+ MoSPIMicrodata.egg-info/PKG-INFO
4
+ MoSPIMicrodata.egg-info/SOURCES.txt
5
+ MoSPIMicrodata.egg-info/dependency_links.txt
6
+ MoSPIMicrodata.egg-info/requires.txt
7
+ MoSPIMicrodata.egg-info/top_level.txt
8
+ MospiMicrodata/MospiMicrodata.py
9
+ MospiMicrodata/__init__.py
@@ -0,0 +1 @@
1
+ MospiMicrodata
@@ -0,0 +1,112 @@
1
+ import requests
2
+ import os
3
+ from typing import List, Dict, Any
4
+
5
+
6
+ def listDatasets(pageNo=1) -> List[Dict[str, Any]]:
7
+
8
+ try:
9
+
10
+ response = requests.get("https://microdata.gov.in/NADA/index.php/api/listdatasets?page="+str(pageNo),headers=None)
11
+
12
+ data = response.json()
13
+
14
+ return data
15
+
16
+ except Exception as e:
17
+ print('Error while downloading the data:',e)
18
+
19
+
20
+ return None
21
+
22
+
23
+ def getDatasets(folderPath, apiKey):
24
+
25
+ page = 1
26
+ errorFlag = False
27
+
28
+ while True:
29
+
30
+ data = listDatasets(page)
31
+
32
+ if data is None:
33
+ print('Error occurred while downloading the data!')
34
+ errorFlag = True
35
+ break
36
+
37
+ rows = data["result"]["rows"]
38
+
39
+ indexed_data = [
40
+ {**item, "index": i}
41
+ for i, item in enumerate(rows, start=1)
42
+ ]
43
+
44
+ for item in indexed_data:
45
+ print(item["id"] + ":" + item["title"])
46
+
47
+ total = int(data["result"]["total"])
48
+ limit = int(data["result"]["limit"])
49
+
50
+ pages = total // limit + (1 if total % limit else 0)
51
+
52
+ user_input = input(
53
+ f"Total pages:{pages}, Page:{page} of {pages},\n"
54
+ "Enter Survey index number (put n to Navigate to Next Page): "
55
+ )
56
+
57
+
58
+ if user_input.strip().lower() == 'n':
59
+ page = page + 1
60
+
61
+ if page > pages:
62
+ print("No more Pages left to browse the data.")
63
+ break
64
+ else:
65
+ continue
66
+
67
+ else:
68
+ if errorFlag == False:
69
+ idno = None
70
+ if user_input.isdigit():
71
+
72
+ for item in indexed_data:
73
+ if item["id"] == user_input:
74
+ idno = item["idno"]
75
+
76
+ if idno is not None:
77
+
78
+ url = "https://microdata.gov.in/NADA/index.php/api/datasets/" + idno + "/fileslist"
79
+
80
+ headers = {
81
+ "Host": "microdata.gov.in",
82
+ "X-API-KEY": apiKey
83
+ }
84
+
85
+ response = requests.get(url, headers=headers)
86
+
87
+ data = response.json()
88
+
89
+ folder = folderPath
90
+
91
+ for item1 in data["files"]:
92
+
93
+ url = "https://microdata.gov.in/NADA/index.php/api/fileslist/download/" + idno + "/" + item1["base64"]
94
+
95
+ response = requests.get(url, headers=headers)
96
+
97
+ filename = os.path.join(folder, item1["name"])
98
+
99
+ with open(filename, "wb") as f:
100
+ f.write(response.content)
101
+ print(filename + ":Downloaded successfully!")
102
+ break
103
+ else:
104
+ print('No such index Exists to download the Data. Kindly check and try again!')
105
+ break
106
+
107
+ else:
108
+ print("Invalid Index no.")
109
+ break
110
+
111
+ else:
112
+ print('Error occurred while downloading the data!')
@@ -0,0 +1,3 @@
1
+ # MospiMicrodata/__init__.py
2
+ from .MospiMicrodata import getDatasets
3
+ __all__ = ["getDatasets"]
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: MoSPIMicrodata
3
+ Version: 1.0.0
4
+ Summary: This package can be used to download the data from MoSPI Microdata Portal (https://microdata.gov.in). Kindly call the getDatasets method with First parameter as location to save the data and second Parameter as API key generated from MicroData Portal Profile Section.
5
+ Author: DIID,Ministry of Statistics and Programme Implementation
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: requests
8
+ Dynamic: author
9
+ Dynamic: description
10
+ Dynamic: description-content-type
11
+ Dynamic: requires-dist
12
+ Dynamic: summary
13
+
14
+ \# MoSPI Microdata access
15
+
16
+
17
+
18
+ This package can be used to access the Microdata available from MoSPI microdata Portal (https://microdata.gov.in)
19
+
20
+
21
+
22
+ \# Features
23
+
24
+
25
+
26
+ use the getDatasets("Path to save the Microdata","your API key downloaded from MosPI Microdata Portal") to choose
27
+
28
+ the Dataset to download.
29
+
30
+
31
+
32
+ For example , you will get the option like this on calling the method
33
+
34
+
35
+
36
+ 277:Annual Survey of Industries 2019-20
37
+
38
+ 275:Annual Survey of Industries 2020-21
39
+
40
+ 256:Annual Survey of Industries 2023-24
41
+
42
+ 255:Comprehensive Modular Survey on Education-NSS 80th Round-2025
43
+
44
+ 254:Periodic Labour Force Survey (PLFS), Key Employment Unemployment Indicators for (January 2024 - December 2024)
45
+
46
+ 239:Comprehensive Modular Survey on Telecom-NSS 80th Round-2025
47
+
48
+ 238:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2023-2024
49
+
50
+ 237:Household Consumption Expenditure Survey: 2023-24
51
+
52
+ 236:Time Use Survey (TUS), January 2024-December 2024
53
+
54
+ 230:Urban Frame Survey (UFS) Summary Data
55
+
56
+ 224:Household Consumption Expenditure Survey: 2022-23
57
+
58
+ 223:Time Use Survey (TUS), January 2019-December 2019
59
+
60
+ 222:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2022-2023
61
+
62
+ 221:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2021-2022
63
+
64
+ 220:Comprehensive Annual Modular Survey (CAMS),NSS 79th round: 2022-23
65
+
66
+ Total pages:13,Page:1 of 13,
67
+
68
+ Enter Survey index number(put n to Navigate to Next Page):
69
+
70
+
71
+
72
+ You can choose the Numeric Index no to download the associated datasets
73
+
74
+
75
+
76
+ \## Installation
77
+
78
+
79
+
80
+ pip install package-name
81
+
82
+
83
+
84
+
85
+
@@ -0,0 +1,72 @@
1
+ \# MoSPI Microdata access
2
+
3
+
4
+
5
+ This package can be used to access the Microdata available from MoSPI microdata Portal (https://microdata.gov.in)
6
+
7
+
8
+
9
+ \# Features
10
+
11
+
12
+
13
+ use the getDatasets("Path to save the Microdata","your API key downloaded from MosPI Microdata Portal") to choose
14
+
15
+ the Dataset to download.
16
+
17
+
18
+
19
+ For example , you will get the option like this on calling the method
20
+
21
+
22
+
23
+ 277:Annual Survey of Industries 2019-20
24
+
25
+ 275:Annual Survey of Industries 2020-21
26
+
27
+ 256:Annual Survey of Industries 2023-24
28
+
29
+ 255:Comprehensive Modular Survey on Education-NSS 80th Round-2025
30
+
31
+ 254:Periodic Labour Force Survey (PLFS), Key Employment Unemployment Indicators for (January 2024 - December 2024)
32
+
33
+ 239:Comprehensive Modular Survey on Telecom-NSS 80th Round-2025
34
+
35
+ 238:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2023-2024
36
+
37
+ 237:Household Consumption Expenditure Survey: 2023-24
38
+
39
+ 236:Time Use Survey (TUS), January 2024-December 2024
40
+
41
+ 230:Urban Frame Survey (UFS) Summary Data
42
+
43
+ 224:Household Consumption Expenditure Survey: 2022-23
44
+
45
+ 223:Time Use Survey (TUS), January 2019-December 2019
46
+
47
+ 222:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2022-2023
48
+
49
+ 221:Annual Survey of Unincorporated Sector Enterprises (ASUSE) of 2021-2022
50
+
51
+ 220:Comprehensive Annual Modular Survey (CAMS),NSS 79th round: 2022-23
52
+
53
+ Total pages:13,Page:1 of 13,
54
+
55
+ Enter Survey index number(put n to Navigate to Next Page):
56
+
57
+
58
+
59
+ You can choose the Numeric Index no to download the associated datasets
60
+
61
+
62
+
63
+ \## Installation
64
+
65
+
66
+
67
+ pip install package-name
68
+
69
+
70
+
71
+
72
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="MoSPIMicrodata",
5
+ version="1.0.0",
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ "requests"
9
+ ],
10
+ long_description=open("README.md").read(),
11
+ long_description_content_type="text/markdown",
12
+ author="DIID,Ministry of Statistics and Programme Implementation",
13
+ description="This package can be used to download the data from MoSPI Microdata " \
14
+ "Portal (https://microdata.gov.in). Kindly call the getDatasets method with First parameter as location to save the data and second Parameter as " \
15
+ "API key generated from MicroData Portal Profile Section.",
16
+ )