Commit 87f71e3b authored by Manas Gabani's avatar Manas Gabani

added master file and function for reading all raw data csv files

parent 25abcd8e
State_Code State_Name Total_Population Percentage_Population_Urban Percentage_Population_0_6_Age_Group Growth_Rate Sex_Ratio Overall_Literacy_Rate Female_Literacy_Rate Male_Literacy_Rate Area_Sq_Km
1 JAMMU & KASHMIR 12549 20.05 16.01 23.71 883 68.74 58.01 78.26 222236
2 HIMACHAL PRADESH 6857 8.69 11.14 12.81 974 83.78 76.6 90.83 55673
3 PUNJAB 27704 29.82 10.62 13.73 893 76.68 71.34 81.48 50362
4 CHANDIGARH 1055 97.25 11.18 17.1 818 86.43 81.38 90.54 114
5 UTTARAKHAND 10117 21.54 13.14 19.17 963 79.63 70.7 88.33 53483
6 HARYANA 25353 24.12 13.01 19.9 877 76.64 66.77 85.38 44212
7 DELHI 16753 77.03 11.76 20.96 866 86.34 80.93 91.03 1483
8 RAJASTHAN 68621 19.26 15.31 21.44 926 67.06 52.66 80.51 342239
9 UTTAR PRADESH 199581 17.31 14.9 20.09 908 69.72 59.26 79.24 240928
10 BIHAR 103805 8.36 17.9 25.07 916 63.82 53.33 73.39 94163
11 SIKKIM 608 9.85 10.05 12.36 889 82.2 76.43 87.29 7096
12 ARUNACHAL PRADESH 1383 16.48 14.66 25.92 920 66.95 59.57 73.69 83743
13 NAGALAND 1981 17.31 14.44 -0.47 931 80.11 76.69 83.29 16579
14 MANIPUR 2722 21.16 12.98 18.65 987 79.85 73.17 86.49 22327
15 MIZORAM 1091 40.42 15.17 22.78 975 91.58 89.4 93.72 21081
16 TRIPURA 3671 14.87 12.1 14.75 961 87.75 83.15 92.18 10486
17 MEGHALAYA 2964 15.32 18.75 27.82 986 75.48 73.78 77.17 22429
18 ASSAM 31169 11.03 14.47 16.93 954 73.18 67.27 78.81 78438
19 WEST BENGAL 991348 24.55 11.07 13.93 947 77.08 71.16 82.67 88752
20 JHARKHAND 32966 18.18 15.89 22.34 947 67.63 56.21 78.45 79714
21 ODISHA 41947 13.15 12 13.97 978 73.45 64.36 82.4 155707
22 CHHATTISGARH 25540 16.39 14.03 22.59 991 71.04 60.59 81.45 135191
23 MADHYA PRADESH 72598 21.99 14.53 20.3 930 70.63 60.02 80.53 308245
24 GUJARAT 60384 31.35 12.41 19.17 918 79.31 70.73 87.23 196024
25 DAMAN & DIU 243 23.61 10.65 53.54 618 87.07 79.59 91.48 112
26 DADRA & NAGAR HAVELI 343 14.72 14.35 55.5 775 77.65 65.93 86.46 451
27 MAHARASHTRA 112373 36.58 11.43 15.99 925 82.91 75.48 89.82 307713
28 ANDHRA PRADESH 84666 24.58 10.21 11.1 992 67.66 59.74 75.56 275045
29 KARNATAKA 61131 29.38 11.21 15.67 968 75.6 68.13 82.85 191791
30 GOA 1458 46 9.57 8.17 968 87.4 81.84 92.81 3702
31 LAKSHADWEEP 64 41.86 11 6.23 946 92.28 88.25 96.11 32
32 KERALA 33388 24.76 9.95 44.86 1084 93.91 91.98 96.02 38863
33 TAMIL NADU 72139 38.1 9.56 15.6 995 80.3 73.86 86.81 130058
34 PUDUCHERRY 1244 52.12 10.25 27.72 1038 86.55 81.22 92.12 479
35 ANDAMAN & NICOBAR ISLANDS 380 30.58 10.4 6.68 878 86.27 81.84 90.11 8249
36 TELANGANA 352 38.67 39.2 13.58 987 66.46 57.92 74.95 114840
\ No newline at end of file
from fileinput import filename
from flask import Flask, flash, request, redirect, url_for, render_template
import urllib.request
import os
from werkzeug.utils import secure_filename
from fileinput import filename
import pandas as pd
import numpy as np
import os
import glob
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
def read_all_csv(path='./rawdata_csv/', extension='csv'):
result = glob.glob(path+'SRC_R*.{}'.format(extension))
df=None
for file in result:
if(df is None):
df=pd.read_csv(file)
else:
df=pd.concat([df,pd.read_csv(file)], ignore_index=True)
df_master=pd.read_csv("SRC_MasterData.csv")
df_master=df_master[['State_Code','State_Name','Total_Population']]
final_df = pd.merge(df, df_master, on='State_Code', how='inner')
final_df['total']=final_df[['Primary_Only','Primary_with_Upper_Primary','Primary with_Upper_Primary_Sec_H.Sec','Upper_Primary_Only','Upper_Primary_with_Sec_H.Sec','Primary_with_Upper_Primary_Sec','Upper_Primary_with _Sec']].sum(axis=1)
final_df['total_by_pop']=final_df['total']/final_df['Total_Population']
final_df=final_df[["Year","State_Name","State_Code","Main_Dimension","Sub_Dimension","Total_Population",'total','total_by_pop']]
return final_df
final_df=read_all_csv()
app = Flask(__name__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment