Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
generated PIE chart(s) & plotting for others states too
Browse files Browse the repository at this point in the history
  • Loading branch information
itzmeanjan committed Sep 12, 2019
1 parent 80c6b80 commit 6ed1f73
Show file tree
Hide file tree
Showing 214 changed files with 17 additions and 23 deletions.
3 changes: 2 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def __calculateSuccess__(result):
filter(lambda v: v.endswith('csv'), listdir(targetPath))), [])
)
) # calculating rate of success of these operation(s)
except Exception:
except Exception as e:
print(e)
return 0.0


Expand Down
32 changes: 11 additions & 21 deletions model/corporateStat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/python3

from datetime import date
from functools import reduce
from re import compile as regex_compile
from csv import reader as csvReader

'''
This class is expected to hold data for a certain company registered
Expand Down Expand Up @@ -38,12 +37,16 @@ def __init__(self, cin, name, status, companyClass, category, subCategory, dor,
'''
@property
def dateOfRegistration(self):
return None if self._dateOfRegistration.lower() == 'na' else date(*[int(i) for i in self._dateOfRegistration.split('-')[-1::-1]])
try:
return date(*[int(i) for i in self._dateOfRegistration.split('-')[-1::-1]])
except Exception:
return None


'''
Designed to hold a list of all companies present under one certain State of India
Designed to hold a stream ( generating all companies, one time subscription )
present under one certain State of India
State, about which we're currently talking, can also be looked up from an instance of this class
'''

Expand All @@ -65,30 +68,17 @@ def importFromCSV(state, targetPath):
we can't just use `,` ( comma ) as field seperator in CSV.
Cause there's `,` ( comma ) present in unexpected places, so
what we're going to do is replace all those unexpected `,` ( commas )
using '' ( blank string ).
One good thing that makes our job easier, is that all malformed ( comma added ) substrings
are places within double quotations.
So we're going to use regular expression for extracting all those substrings,
which are having `,` within it, and replace that using properly formatted substring(s)
And we finally construct properly formatted string, using `reduce()`.
what we're going to handle that using python's very own `csv` module,
while using `excel` as dialect.
'''
def __fixCommaIssueInAddress__(stringToFix):
# this regex will find out a certain substring ( within a string ), present under double quotation
# multiple of them can be extracted using re.findall() method
return reduce(lambda acc, cur: acc.replace(
cur, cur.replace(',', '').replace('"', '')), regex_compile(r'\"([^"]*)\"').findall(stringToFix), stringToFix)

companiesUnderStateObject = None # this is what's to be returned
try:
# reads CSV file content in splitted line form,
# which is to be processed for creating an instance of Company class
with open(targetPath, mode='r', encoding='ISO-8859-1') as fd:
companiesUnderStateObject = CompaniesUnderState(
state, (Company(*__fixCommaIssueInAddress__(line).split(',')[:-2]) for line in fd.readlines()[1:]))
state, (Company(*i[:-2]) for i in csvReader(fd.readlines()[1:])))
except Exception:
companiesUnderStateObject = None
finally:
Expand Down
Binary file added plots/mca_andaman_21042018_company_category.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/mca_andaman_21042018_company_class.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/mca_andaman_21042018_company_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/mca_assam_21042018_company_category.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/mca_assam_21042018_company_class.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/mca_assam_21042018_company_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/mca_assam_21042018_company_subCategory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/mca_bihar_21042018_company_category.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/mca_bihar_21042018_company_class.png
Binary file added plots/mca_bihar_21042018_company_status.png
Binary file added plots/mca_bihar_21042018_company_subCategory.png
Binary file added plots/mca_chandigarh_21042018_company_class.png
Binary file added plots/mca_chandigarh_21042018_company_status.png
Binary file added plots/mca_damananddiu_21042018_company_class.png
Binary file added plots/mca_delhi_21042018_company_category.png
Binary file added plots/mca_delhi_21042018_company_class.png
Binary file added plots/mca_delhi_21042018_company_status.png
Binary file added plots/mca_delhi_21042018_company_subCategory.png
Binary file added plots/mca_goa_21042018_company_category.png
Binary file added plots/mca_goa_21042018_company_class.png
Binary file added plots/mca_goa_21042018_company_status.png
Binary file added plots/mca_goa_21042018_company_subCategory.png
Binary file added plots/mca_gujarat_21042018_company_category.png
Binary file added plots/mca_gujarat_21042018_company_class.png
Binary file added plots/mca_gujarat_21042018_company_status.png
Binary file added plots/mca_haryana_21042018_company_category.png
Binary file added plots/mca_haryana_21042018_company_class.png
Binary file added plots/mca_haryana_21042018_company_status.png
Binary file added plots/mca_jharkhand_21042018_company_category.png
Binary file added plots/mca_jharkhand_21042018_company_class.png
Binary file added plots/mca_jharkhand_21042018_company_status.png
Binary file added plots/mca_karnataka_21042018_company_category.png
Binary file added plots/mca_karnataka_21042018_company_class.png
Binary file added plots/mca_karnataka_21042018_company_status.png
Binary file added plots/mca_kerala_21042018_company_category.png
Binary file added plots/mca_kerala_21042018_company_class.png
Binary file added plots/mca_kerala_21042018_company_status.png
Binary file added plots/mca_kerala_21042018_company_subCategory.png
Binary file added plots/mca_lakshadweep_21042018_company_class.png
Binary file added plots/mca_lakshadweep_21042018_company_status.png
Binary file added plots/mca_maharashtra_21042018_company_class.png
Binary file added plots/mca_maharashtra_21042018_company_status.png
Binary file added plots/mca_manipur_21042018_company_class.png
Binary file added plots/mca_manipur_21042018_company_status.png
Binary file added plots/mca_meghalaya_21042018_company_category.png
Binary file added plots/mca_meghalaya_21042018_company_class.png
Binary file added plots/mca_meghalaya_21042018_company_status.png
Binary file added plots/mca_mizoram_21042018_company_category.png
Binary file added plots/mca_mizoram_21042018_company_class.png
Binary file added plots/mca_mizoram_21042018_company_status.png
Binary file added plots/mca_nagaland_21042018_company_category.png
Binary file added plots/mca_nagaland_21042018_company_class.png
Binary file added plots/mca_nagaland_21042018_company_status.png
Binary file added plots/mca_odisha_21042018_company_category.png
Binary file added plots/mca_odisha_21042018_company_class.png
Binary file added plots/mca_odisha_21042018_company_status.png
Binary file added plots/mca_odisha_21042018_company_subCategory.png
Binary file added plots/mca_puducherry_21042018_company_class.png
Binary file added plots/mca_puducherry_21042018_company_status.png
Binary file added plots/mca_punjab_21042018_company_category.png
Binary file added plots/mca_punjab_21042018_company_class.png
Binary file added plots/mca_punjab_21042018_company_status.png
Binary file added plots/mca_punjab_21042018_company_subCategory.png
Binary file added plots/mca_rajasthan_21042018_company_category.png
Binary file added plots/mca_rajasthan_21042018_company_class.png
Binary file added plots/mca_rajasthan_21042018_company_status.png
Binary file added plots/mca_sikkim_21042018_company_category.png
Binary file added plots/mca_sikkim_21042018_company_class.png
Binary file added plots/mca_sikkim_21042018_company_status.png
Binary file added plots/mca_sikkim_21042018_company_subCategory.png
Binary file added plots/mca_tamilnadu_21042018_company_category.png
Binary file added plots/mca_tamilnadu_21042018_company_class.png
Binary file added plots/mca_tamilnadu_21042018_company_status.png
Binary file added plots/mca_telangana_21042018_company_category.png
Binary file added plots/mca_telangana_21042018_company_class.png
Binary file added plots/mca_telangana_21042018_company_status.png
Binary file added plots/mca_tripura_21042018_company_category.png
Binary file added plots/mca_tripura_21042018_company_class.png
Binary file added plots/mca_tripura_21042018_company_status.png
Binary file added plots/mca_uttarakhand_21042018_company_class.png
Binary file added plots/mca_uttarakhand_21042018_company_status.png
Binary file added plots/mca_uttarpradesh_21042018_company_class.png
Binary file modified plots/mca_westbengal_21042018_company_principalBusinessActivity.png
5 changes: 4 additions & 1 deletion util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import reduce
from os.path import dirname, exists
from os import mkdir
from time import localtime, time
try:
from matplotlib import pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
Expand Down Expand Up @@ -123,7 +124,9 @@ def plotCompanyRegistrationDateWiseCategorizedData(dataSet, targetPath, title):
'size': 12
}
# a range from `first when a company was registered` to `nearest year upto which we have any status`
x = range(min(dataSet), max(dataSet) + 1)
# filtering out improper years ( may be higher than current year ), lets us clean dataset, so that things go smooth
x = range(min(dataSet), max(
filter(lambda v: v < (localtime(time()).tm_year + 1), dataSet)) + 1)
y = [dataSet.get(i, 0) for i in x]
plt.figure(figsize=(24, 12), dpi=100)
# creating major x-tick locator every 10 years
Expand Down

0 comments on commit 6ed1f73

Please sign in to comment.