Informatics Practices Project
Informatics Practices Project
ROLL NO:
CERTIFICATE
This is to certify that Aryan Gaur has successfully completed his informatics
practices project on the topic of "Indian Diaspora" for Class 12 under my guidance.
Aryan Gaur has demonstrated a deep understanding of the topic and has
conducted the experiment with utmost care and precision.
PAGE 1
ACKNOWLEDGEMENT
I would like to express my sincere gratitude to my teacher, Ms. Richa Rana, for her
guidance and support throughout this project on the topic of "Indian Diaspora"
Richa Ma’am has been a patient and helpful mentor, and she has always been
willing to answer my questions and provide me with feedback. He has helped me
to develop my research skills and to write a clear and concise project report.
I am grateful for the opportunity to have worked on this project, and I am proud of
the results that I have achieved.
ARYAN GAUR
N.W.S. GZB
Date:
PAGE 2
INDEX
1. Objective
2. Introduction
3. Software requirements
4. Source Code
5. Output
6.Conclusion
7. Bibliography
PAGE 3
OBJECTIVE
The objectives covered in this project are outlined as follows:
PAGE 4
INTRODUCTION
Key Features:
Data Manipulation:
o Users can filter migration data based on their preferences, choosing either specific
years or countries for detailed analysis
Data Analysis:
o The tool provides statistical analysis options, allowing users to explore maximum,
minimum, average, and total migration values. Analysis can be performed for
individual years or countries.
Data Visualization:
o Users have the option to visualize migration data using line charts, bar charts, and
histograms, providing a graphical representation of trends and patterns.
MySQL Integration:
o The tool seamlessly connects to a MySQL database named "12pcmborad", enabling
users to view the existing data, insert new values, and perform operations such as
deleting records or columns.
User-Friendly Menu:
o The program is designed with a user-friendly menu, allowing users to navigate
through various functionalities easily. The menu-driven approach ensures a
smooth and interactive experience.
PAGE 5
SOFTWARE REQUIREMENTS:
Python:
The code is written in Python, so you need a Python interpreter installed on your system.
Download Python from the official website: Python Downloads
LIBRARIES:
Ensure that the required Python libraries are installed. You can install them using the following
commands in your terminal or command prompt:
MYSQL SERVER:
The code interacts with a MySQL database, so you need a MySQL server installed and running.
Download and install MySQL Server: MySQL Downloads
You also need to create a database named "12pcmborad" with a table named "migration" in your MySQL
server. The structure of the table should match the expected data in the code.
Make sure the MySQL server is running, and you have the necessary credentials (host, username,
password) to connect to it.
Update the MySQL connection details in the code accordingly.
CSV File:
The code reads data from a CSV file. Make sure you have the file "ippract2024.csv" available at the
specified location in the code ("C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Data\\ippract2024.csv").
Matplotlib Backend (for Plotting):
Depending on your environment, you might need to set up a matplotlib backend for displaying plots. If
you encounter issues with plot rendering, you can try adding the following lines at the beginning of your
script:
Make sure to adapt these requirements based on your specific operating system and
environment. Additionally, consider using a virtual environment to manage dependencies for
this project.
PAGE 6
SOURCE CODE:
1. import pandas as pd
2. import numpy as np
3. import matplotlib.pyplot as plt
4. import mysql.connector
5.
6. df1 = pd.read_csv("C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Data\\fake.csv")
7. for i in range(0, 11):
8. print(
9. "1- Reading CSV \n2- Data Manupulation \n3- Data Analysis \n4- Data
Visualisation \n5- MySQL Connect \n6- Exit"
10. )
11. n = int(input("Choose your option"))
12. if n == 1:
13. print("Enter (yes) to print csv table")
14. a = input("enter")
15. if a == "yes":
16. df1 = pd.read_csv(
17. "C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Data\\fake.csv"
18. )
19. print(df1)
20. else:
21. print("Invalid Input")
22. elif n == 2:
23. for j in range(0, 4):
24. print(
25. "1- filter migration of year(between 2000 and 2016) \n2- filter
migration of country \n3- Back to Main Menu"
26. )
27. df1 = pd.read_csv(
28. "C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Data\\fake.csv"
29. )
30. b = int(input("choose your option"))
31. if b == 1:
32. b1 = int(input("enter year"))
33. if b1 == 2000:
34. b2 = df1.loc[:, ["Country", "2000"]]
35. print(b2)
36. elif b1 == 2001:
37. b2 = df1.loc[:, ["Country", "2001"]]
38. print(b2)
39. elif b1 == 2002:
40. b2 = df1.loc[:, ["Country", "2002"]]
41. print(b2)
42. elif b1 == 2003:
43. b2 = df1.loc[:, ["Country", "2003"]]
44. print(b2)
45. elif b1 == 2004:
46. b2 = df1.loc[:, ["Country", "2004"]]
47. print(b2)
PAGE 7
48. elif b1 == 2005:
49. b2 = df1.loc[:, ["Country", "2005"]]
50. print(b2)
51. elif b1 == 2006:
52. b2 = df1.loc[:, ["Country", "2006"]]
53. print(b2)
54. elif b1 == 2007:
55. b2 = df1.loc[:, ["Country", "2007"]]
56. print(b2)
57. elif b1 == 2008:
58. b2 = df1.loc[:, ["Country", "2008"]]
59. print(b2)
60. elif b1 == 2009:
61. b2 = df1.loc[:, ["Country", "2009"]]
62. print(b2)
63. elif b1 == 2010:
64. b2 = df1.loc[:, ["Country", "2010"]]
65. print(b2)
66. elif b1 == 2011:
67. b2 = df1.loc[:, ["Country", "2011"]]
68. print(b2)
69. elif b1 == 2012:
70. b2 = df1.loc[:, ["Country", "2012"]]
71. print(b2)
72. elif b1 == 2013:
73. b2 = df1.loc[:, ["Country", "2013"]]
74. print(b2)
75. elif b1 == 2014:
76. b2 = df1.loc[:, ["Country", "2014"]]
77. print(b2)
78. elif b1 == 2015:
79. b2 = df1.loc[:, ["Country", "2015"]]
80. print(b2)
81. elif b1 == 2016:
82. b2 = df1.loc[:, ["Country", "2016"]]
83. print(b2)
84. else:
85. print("Invalid Input")
86. elif b == 2:
87. print(
88. "1-Australia \n2-Austria \n3-Belgium \n4-Canada \n5-Chile \
n6-Denmark \n7-Finland \n8-France \n9-Germany \n10-Israel \n11-Italy \n12-Korea
Luxembourg \n13-Netherlands \n14-New Zealand \n15-Norway \n16-Poland \n17-Spain \
n18-Sweden \n19-United Kingdom \n20-United States"
89. )
90. b3 = int(input("choose your option"))
91. if b3 == 1:
92. b4 = df1.loc[0, :]
93. print(b4)
94. elif b3 == 2:
95. b4 = df1.loc[1, :]
96. print(b4)
97. elif b3 == 3:
PAGE 8
98. b4 = df1.loc[2, :]
99. print(b4)
100. elif b3 == 4:
101. b4 = df1.loc[3, :]
102. print(b4)
103. elif b3 == 5:
104. b4 = df1.loc[4, :]
105. print(b4)
106. elif b3 == 6:
107. b4 = df1.loc[5, :]
108. print(b4)
109. elif b3 == 7:
110. b4 = df1.loc[6, :]
111. print(b4)
112. elif b3 == 8:
113. b4 = df1.loc[7, :]
114. print(b4)
115. elif b3 == 9:
116. b4 = df1.loc[8, :]
117. print(b4)
118. elif b3 == 10:
119. b4 = df1.loc[9, :]
120. print(b4)
121. elif b3 == 11:
122. b4 = df1.loc[10, :]
123. print(b4)
124. elif b3 == 12:
125. b4 = df1.loc[11, :]
126. print(b4)
127. elif b3 == 13:
128. b4 = df1.loc[12, :]
129. print(b4)
130. elif b3 == 14:
131. b4 = df1.loc[13, :]
132. print(b4)
133. elif b3 == 15:
134. b4 = df1.loc[14, :]
135. print(b4)
136. elif b3 == 16:
137. b4 = df1.loc[15, :]
138. print(b4)
139. elif b3 == 17:
140. b4 = df1.loc[16, :]
141. print(b4)
142. elif b3 == 18:
143. b4 = df1.loc[17, :]
144. print(b4)
145. elif b3 == 19:
146. b4 = df1.loc[18, :]
147. print(b4)
148. elif b3 == 20:
149. b4 = df1.loc[19, :]
150. print(b4)
PAGE 9
151. else:
152. print("Invalid Input")
153. elif b == 3:
154. break
155. else:
156. print("Invalid Input")
157. elif n == 3:
158. for k in range(8):
159. print(
160. "1- Maximum migration \n2- Minimum migration \n3- Average
migration \n4- Sum of migration \n5- Back to Main Menu"
161. )
162. df1 = pd.read_csv(
163. "C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Data\\fake.csv"
164. )
165. c = int(input("Choose your option"))
166. if c == 1:
167. print("1- for Years \n2- for Country")
168. c1 = int(input("choose your option"))
169. if c1 == 1:
170. print(df1.max(numeric_only=True))
171. elif c1 == 2:
172. df1.set_index("Country", inplace=True)
173. print(df1.max(axis=1))
174. else:
175. print("Invalid Input")
176. elif c == 2:
177. print("1- for Years \n2- for Country")
178. c1 = int(input("choose your option"))
179. if c1 == 1:
180. print(df1.min(numeric_only=True))
181. elif c1 == 2:
182. df1.set_index("Country", inplace=True)
183. print(df1.min(axis=1))
184. else:
185. print("Invalid Input")
186. elif c == 3:
187. print("1- for Years \n2- for Country")
188. c1 = int(input("choose your option"))
189. if c1 == 1:
190. print(df1.mean(numeric_only=True))
191. elif c1 == 2:
192. df1.set_index("Country", inplace=True)
193. print(df1.mean(axis=1))
194. else:
195. print("Invalid Input")
196. elif c == 4:
197. print("1- for Years \n2- for Country")
198. c1 = int(input("choose your option"))
199. if c1 == 1:
200. print(df1.sum(numeric_only=True))
201. elif c1 == 2:
202. df1.set_index("Country", inplace=True)
PAGE 10
203. print(df1.sum(axis=1))
204. else:
205. print("Invalid Input")
206. elif c == 5:
207. break
208. else:
209. print("Invalid Input")
210. elif n == 4:
211. for l in range(6):
212. print("1- Line Chart \n2- Bar Chart \n3- Histogram \n4- Back to
Main Menu")
213. d = int(input("choose your option"))
214. if d == 1:
215. df1 = pd.read_csv("C:\\Users\\Amit Kumar\\OneDrive\\
Desktop\\fake.csv")
216. df1.plot(kind="line", x="Country")
217. plt.show()
218. if d == 2:
219. df1 = pd.read_csv("C:\\Users\\Amit Kumar\\OneDrive\\
Desktop\\fake.csv")
220. df1.plot(kind="bar", x="Country")
221. plt.show()
222. if d == 3:
223. df1 = pd.read_csv("C:\\Users\\Amit Kumar\\OneDrive\\
Desktop\\fake.csv")
224. df1.plot(kind="hist", x="Country")
225. plt.show()
226. elif d == 4:
227. break
228. else:
229. print("Invalid Input")
230. elif n == 5:
231. for f in range(6):
232. print(
233. "1- Show MySQL Table \n2- Insert values \n3- Delete Records
\n4- Back to Main Menu"
234. )
235. e = int(input("choose your option"))
236. if e == 1:
237. mydb = mysql.connector.connect(
238. host="localhost", user="root", password="hello",
database="vaibhav"
239. )
240. mycursor = mydb.cursor()
241. mycursor.execute("SELECT * FROM migration;")
242. myresult = mycursor.fetchall()
243. for x in myresult:
244. print(x)
245. elif e == 2:
246. print("1- Add Column \n2- Add Row \n3- Back to Main Menu")
247. a = int(input("choose your option"))
248. if a == 1:
249. mydb = mysql.connector.connect(
PAGE 11
250. host="localhost",
251. user="root",
252. password="hello",
253. database="vaibhav",
254. )
255. mycursor = mydb.cursor()
256. year = input("Enter the year")
257. column_name = f"Y_{year}"
258. data_type = "INT"
259. a = int(input("Australia-migration"))
260. b = int(input("Austria-migration"))
261. c = int(input("Belgium-migration"))
262. h = int(input("Canada-migration"))
263. e = int(input("Chile-migration"))
264. w = int(input("Denmark-migration"))
265. r = int(input("Finland-migration"))
266. q = int(input("France-migration"))
267. n = int(input("Germany-migration"))
268. t = int(input("Israel-migration"))
269. a1 = int(input("Italy-migration"))
270. a2 = int(input("Korea-migration"))
271. a3 = int(input("Luxembourg-migration"))
272. a4 = int(input("Netherlands-migration"))
273. a5 = int(input("New Zealand-migration"))
274. a6 = int(input("Norway-migration"))
275. a7 = int(input("Poland-migration"))
276. a11 = int(input("Spain-migration"))
277. a9 = int(input("Sweden-migration"))
278. a10 = int(input("United Kingdom-migration"))
279. b1 = int(input("United States-migration"))
280. sql = f"ALTER TABLE migration ADD COLUMN {column_name}
{data_type};"
281. mycursor.execute(sql)
282. mydb.commit()
283. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'australia';"
284. mycursor.execute(sql2, (a,))
285. mydb.commit()
286. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'austria';"
287. mycursor.execute(sql2, (b,))
288. mydb.commit()
289. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'belgium';"
290. mycursor.execute(sql2, (c,))
291. mydb.commit()
292. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'canada';"
293. mycursor.execute(sql2, (h,))
294. mydb.commit()
295. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'chile';"
296. mycursor.execute(sql2, (e,))
PAGE 12
297. mydb.commit()
298. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'denmark';"
299. mycursor.execute(sql2, (w,))
300. mydb.commit()
301. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'finland';"
302. mycursor.execute(sql2, (r,))
303. mydb.commit()
304. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'france';"
305. mycursor.execute(sql2, (q,))
306. mydb.commit()
307. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'germany';"
308. mycursor.execute(sql2, (n,))
309. mydb.commit()
310. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'israel';"
311. mycursor.execute(sql2, (t,))
312. mydb.commit()
313. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'italy';"
314. mycursor.execute(sql2, (a1,))
315. mydb.commit()
316. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'korea';"
317. mycursor.execute(sql2, (a2,))
318. mydb.commit()
319. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'Luxembourg';"
320. mycursor.execute(sql2, (a3,))
321. mydb.commit()
322. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'Netherlands';"
323. mycursor.execute(sql2, (a4,))
324. mydb.commit()
325. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'New Zealand';"
326. mycursor.execute(sql2, (a5,))
327. mydb.commit()
328. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'norway';"
329. mycursor.execute(sql2, (a6,))
330. mydb.commit()
331. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'Poland';"
332. mycursor.execute(sql2, (a7,))
333. mydb.commit()
334. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'spain';"
335. mycursor.execute(sql2, (a11,))
336. mydb.commit()
PAGE 13
337. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'Sweden';"
338. mycursor.execute(sql2, (a9,))
339. mydb.commit()
340. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'United Kingdom';"
341. mycursor.execute(sql2, (a10,))
342. mydb.commit()
343. sql2 = f"UPDATE migration SET {column_name} = %s where
country= 'United States';"
344. mycursor.execute(sql2, (b1,))
345. mydb.commit()
346.
347. myresult = mycursor.fetchall()
348. for x in myresult:
349. print(x)
350. elif a == 2:
351. mydb = mysql.connector.connect(
352. host="localhost",
353. user="root",
354. password="hello",
355. database="vaibhav",
356. )
357. mycursor = mydb.cursor()
358. values = (
359. input("enter country"),
360. int(input("migration in year 2000")),
361. int(input("migration in year 2001")),
362. int(input("migration in year 2002")),
363. int(input("migration in year 2003")),
364. int(input("migration in year 2004")),
365. int(input("migration in year 2005")),
366. int(input("migration in year 2006")),
367. int(input("migration in year 2007")),
368. int(input("migration in year 2008")),
369. int(input("migration in year 2009")),
370. int(input("migration in year 2010")),
371. int(input("migration in year 2011")),
372. int(input("migration in year 2012")),
373. int(input("migration in year 2013")),
374. int(input("migration in year 2014")),
375. int(input("migration in year 2015")),
376. int(input("migration in year 2016")),
377. )
378. sql = f"INSERT INTO
migration(country,Y_2000,Y_2001,Y_2002,Y_2003,Y_2004,Y_2005,Y_2006,Y_2007,Y_2008,
Y_2009,Y_2010,Y_2011,Y_2012,Y_2013,Y_2014,Y_2015,Y_2016) VALUES (%s,%s,%s,%s,%s,
%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);"
379. mycursor.execute(sql, values)
380. mydb.commit()
381. elif a == 3:
382. break
383. else:
PAGE 14
384. print("Invalid Input")
385. elif e == 3:
386. print("1-Delete Row \n2-Delete Column \n3- Back to Main
Menu")
387. w = int(input("choose your option"))
388. if w == 1:
389. mydb = mysql.connector.connect(
390. host="localhost",
391. user="root",
392. password="hello",
393. database="vaibhav",
394. )
395. mycursor = mydb.cursor()
396. o = input("enter country name to delete")
397. sql = f"DELETE FROM migration WHERE country=%s;"
398. mycursor.execute(sql)
399. mydb.commit()
400. elif w == 2:
401. mydb = mysql.connector.connect(
402. host="localhost",
403. user="root",
404. password="hello",
405. database="vaibhav",
406. )
407. mycursor = mydb.cursor()
408. o = input("enter column to delete")
409. sql = f"ALTER TABLE migration DROP column {o};"
410. mycursor.execute(sql)
411. mydb.commit()
412. elif w == 3:
413. break
414. else:
415. print("Invalid Input")
416. elif e == 4:
417. break
418. else:
419. print("Invalid Input")
420. elif n == 6:
421. print("Thank You......... ... ...... ..")
422. break
423. else:
424. print("INVALID INPUT \nPlease Try Again... ")
425.
426.
PAGE 15
OUTPUT:
PAGE 16
CONCLUSION
The presented Python script offers a robust and multifaceted solution for handling migration
data through a combination of data manipulation, analysis, and visualization techniques.
Its modular design and diverse functionalities cater to the needs of users seeking a
comprehensive tool for understanding migration trends across different countries and
over multiple years.
Data Manipulation and Analysis: The code begins by reading migration data from a CSV file,
providing users with a clear overview of the dataset. It then allows for various data
manipulations, such as filtering migration data based on specified years or countries. These
manipulations enable users to extract and focus on specific subsets of the data, aiding in more
targeted analyses.
The data analysis section of the script is a standout feature, offering a range of statistical
measures for users to derive insights. Users can easily obtain maximum, minimum, average,
and total migration values, either across all years or for specific countries. The flexibility in
PAGE 17
choosing the analysis dimension (years or countries) adds exceptionality to the insights
users can extract from the dataset.
Data Visualization: The script leverages the matplotlib library to create visual
representations of the migration data. Users can generate line charts, bar charts, and
histograms, providing a visual narrative of migration patterns. The ability to choose between
these visualization types adds versatility to the exploration process, enabling users to select the
representation that best suits their analytical goals.
MySQL Integration: The integration with MySQL introduces a database aspect to the project,
enabling users to store, retrieve, and manage migration data persistently. This functionality
extends the utility of the code, particularly for those who wish to maintain a centralized and
structured database for their migration data.
In conclusion, this Python script serves as a valuable tool for exploring, analysing, and
visualizing migration data. Its user-friendly interface, combined with powerful data
manipulation and analysis capabilities, positions it as a versatile resource for researchers,
analysts, and enthusiasts interested in gaining meaningful insights into migration trends. The
integration with MySQL adds a layer of sophistication, making it suitable for projects requiring
persistent data storage. As a comprehensive solution, this code stands as a testament to the
potential of Python in the realm of data science and analysis.
BIBLIOGRAPHY
NCERT Textbook:
o https://ncert.nic.in/textbook.php?leip1=1-7
Google:
o https://www.google.com
Python:
o https://www.python.org.in
MYSQL:
o https://www.mysql.org
Geeksforgeeks:
o https://www.geeksforgeeks.org
PAGE 18
W3Schools:
o https://www.w3schools.com/als
PAGE 19