예제 #1
0
def contractor(argv):
    contractorIDList=[]
    top50contractorsIDList=[]
    contractorID_amount={}
    amountList=[]
    contractorID_contractorName={}
    top50contractorsNamesList=[]

    with open(argv[1], 'rU') as f:
        reader=csv.reader(f)
        for row in reader:
            if int(row[12]) not in contractorIDList:
                contractorIDList.append(int(row[12]))
                contractorID_contractorName[int(row[12])]=row[11]    

    for contractorID in contractorIDList:
        
        with open(argv[1], 'rU') as f:
            reader = csv.reader(f)
            #reader.next()
            rowTotal=0
            amtTotal=0
            completedWorksTotal=0
            inprogressWorksTotal=0
            for row in reader:
                #print(row[12])
                #print contractorID
                #time.sleep(1)
                if int(row[12])==contractorID:
                    rowTotal+=1
                    amtTotal=amtTotal+int(row[14])
                    if row[17] == 'completed':
                        completedWorksTotal+=1
                    if row[17] == 'inprogress':
                        inprogressWorksTotal+=1

        amtTotalstr=putCommas(amtTotal)
        rowTotalstr=putCommas(rowTotal)
        completedWorksTotalstr=putCommas(completedWorksTotal)
        inprogressWorksTotalstr=putCommas(inprogressWorksTotal)
        if (amtTotal not in amountList):
            amountList.append(amtTotal)
        contractorID_amount[amtTotal]=contractorID



    amountList.sort()
    amountList.reverse()
    print('-----------------------------')
    #print(nlargest(50,amountList))
    top50amount=(nlargest(50,amountList))
    for number in amountList:
        top50contractorsIDList.append(contractorID_amount[number])
    for ID in top50contractorsIDList:
        top50contractorsNamesList.append(contractorID_contractorName[ID])
    #print contractorID_amount
    return top50contractorsNamesList, top50amount
예제 #2
0
def worktype(argv):
    majorIDList = []

    with open(argv[1], "rU") as f:
        reader = csv.reader(f)
        for row in reader:
            if int(row[2]) not in majorIDList:
                majorIDList.append(int(row[2]))

    for majorID in majorIDList:
        with open(argv[1], "rU") as f:
            reader = csv.reader(f)
            # reader.next()
            rowTotal = 0
            amtTotal = 0
            completedWorksTotal = 0
            inprogressWorksTotal = 0
            contractorsList = []
            for row in reader:
                if row[2] == str(majorID):
                    rowTotal += 1
                    amtTotal = amtTotal + int(row[14])
                    if row[17] == "completed":
                        completedWorksTotal += 1
                    if row[17] == "inprogress":
                        inprogressWorksTotal += 1
                    if row[11] not in contractorsList:
                        contractorsList.append(row[11])

        amtTotalstr = putCommas(amtTotal)
        rowTotalstr = putCommas(rowTotal)
        completedWorksTotalstr = putCommas(completedWorksTotal)
        inprogressWorksTotalstr = putCommas(inprogressWorksTotal)
        contractorsTotal = str(len(contractorsList))
        print("Generating HTML for work type " + str(majorID))
        print("Total amount for this work type: " + amtTotalstr)
        print("Total number of works in this work type " + rowTotalstr)
        with open(os.path.join(argv[2], "worktype", "worktype_" + str(majorID) + ".html"), "w+") as k:
            k.write(
                """<!DOCTYPE html>\n
                <html lang=\"en\">\n
                <head>\n
                <title>Smart City</title>\n<meta charset=\"utf-8\">\n
                <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n
                <script src=\"../commonfiles/sorttable.js\"></script>\n
                <link rel=\"stylesheet\" href=\"../commonfiles/bootstrap.css\">\n
                <script src=\"../commonfiles/jquery.min.js\"></script>\n
                <script src=\"../commonfiles/bootstrap.min.js\"></script>\n
                <script src=\"../commonfiles/addons.js\"></script>\n
            </head>\n<body>\n<div class=\"container\">\n<img src="../images/hdmc-logo.png" width="140em" height="140em" style="display:inline-block; margin-right:1em; margin-left:7em;">\n
    <h2 style=\"text-align:center; display:inline-block;\"><a href="../allworks/allworks.html">Hubballi Dharwad Smart Cities Project</a></h2>\n
    <img src="../images/smartcitylogo.jpg" width="150em" height="150em" style="display:inline-block; margin-left:1em; margin-top:1.2em;">"""
            )

            k.write(
                """<h4 style="display:inline-block;margin-left:5em"> Total number of works: """
                + rowTotalstr
                + """</h4>"""
            )
            k.write(
                """<h4 style="display:inline-block; margin-left:7em;"> Completed works: """
                + completedWorksTotalstr
                + """</h4>"""
            )
            k.write(
                """<h4 style="display:inline-block; margin-left:7em;"> In progress works: """
                + inprogressWorksTotalstr
                + """</h4>"""
            )
            k.write(
                """<h4 style="display:inline-block; margin-left:5em;"> Total amount spent: &#8377 """
                + amtTotalstr
                + """</h4>"""
            )
            k.write(
                """<h4 style="display:inline-block; margin-left:3.5em;"> Total number of contractors: """
                + contractorsTotal
                + """</h4>"""
            )

            k.write(
                """
            <table class=\"table table-responsive sortable\">\n
            <thead>\n
            <tr>\n
            <th style=\"width:5%\">Ward</th>\n
            <th style=\"width:48%\">Work Description</th>\n
            <th style=\"width:10%\">Work Order Date</th>\n
            <th style=\"width:10%\">Work Completion Date</th>\n
            <th>Work Type</th>\n
            <th>Source of Income</th>\n
            <th style=\"width:7%\">Contractor</th>\n
            <th>Amount Sanctioned</th>\n
            <th>Status</th>\n
            </tr>\n
            </thead>\n
            <tbody>
            <a href="#" class="scrollup">Go to top</a>
            """
            )

            with open(argv[1], "rU") as f:
                reader = csv.reader(f)
                for row in reader:
                    # print row[1]
                    if row[2] == str(majorID):
                        year = int(row[16][-2:])
                        workID = row[0][:-3].replace(",", "")
                        workID = int(workID)
                        orderDate = dateConv(row[15])
                        completionDate = dateConv(row[16])
                        # print (workID)
                        k.write("<tr>")

                        # ward number
                        k.write(
                            '<td class = "span1"><a href="../wardworks/ward_'
                            + row[1]
                            + '.html" target="_blank">'
                            + row[1]
                            + "</a></td>"
                        )

                        # work description
                        if len(row[4]) <= 4:
                            k.write("<td>Info not available</td>")
                        else:
                            if row[2] == "1" or row[2] == "2" or row[2] == "3":
                                k.write(
                                    '<td><a href="../worknum/work_'
                                    + str(workID)
                                    + '.html" target="_blank">'
                                    + row[4]
                                    + "</a></td>"
                                )
                            else:
                                k.write("<td>" + row[4] + "</td>")

                        # work order date
                        k.write("<td sorttable_customkey=" + orderDate + ">" + row[15] + "</td>")

                        # work completion date
                        k.write("<td sorttable_customkey=" + completionDate + ">" + row[16] + "</td>")

                        # type of work
                        k.write(
                            '<td><a href="../worktype/worktype_'
                            + row[2]
                            + '.html" target="_blank">'
                            + row[20]
                            + "</a></td>"
                        )

                        # source of income
                        k.write("<td>" + row[19] + "</td>")

                        # contractor
                        k.write(
                            '<td><a href="../contractors/contractor_'
                            + row[12]
                            + '.html" target="_blank">'
                            + row[11]
                            + "</a></td>"
                        )

                        # amount
                        amt = putCommas(int(row[14]))
                        k.write("<td>" + amt + "</td>")

                        # status
                        try:
                            if row[17] == "completed":
                                k.write(
                                    '<td style="color:#43ac6a">' + row[17][0].upper() + row[17][1:].lower() + "</td>"
                                )
                            else:
                                k.write(
                                    '<td style="color:#d32a0e">' + row[17][0].upper() + row[17][1:].lower() + "</td>"
                                )
                        except:
                            pass

                        k.write("</tr>")

            k.write("</tbody>\n</table>\n</div>\n</body>\n</html>")
예제 #3
0
def workdetails(argv):

    workIDList =[]
    filepath = argv[2].split('root/',1)[0]+'data/HD-works-details-2014-15.csv'
    #print filepath
    with open(filepath, 'rU') as f:
        csvHandle = csv.reader(f)
        csvHandle.next()

        for row in csvHandle:
            wid = int(row[0])
            if wid not in workIDList:
                workIDList.append(wid)

    for number in workIDList:
        rowTotal=0
        amtTotal=0
        with open(filepath, 'rU') as f:
            reader = csv.reader(f)
            reader.next()
            for row in reader:
                if int(row[0])==number:
                    rowTotal+=1
                    try:
                        amtTotal=amtTotal+int(float(row[2])*float(row[5].replace(',','')))
                    except:
                        pass

        amtTotalstr=putCommas(amtTotal)
        rowTotalstr=putCommas(rowTotal)

        with open(os.path.join(argv[2],'worknum','work_'+str(number)+'.html'), 'w+') as k:
            print('Generating HTML for work ID: ' + str(number))
            #print 'Total amount: ' + amtTotalstr
            #print 'Total number of rows: ' + rowTotalstr
            k.write("""<!DOCTYPE html>\n<html lang=\"en\">\n<head><style>table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after {content: \" \\25B4\\25BE\"}display: inline-block;
                    width: 24px;
                    height: 24px;
                    }
                    th.sorttable_sorted::after {
                    background: url(up.png);
                    background-size: contain;
                    }
                    th.sorttable_sorted_reverse::after {
                    background: url(down.png);
                    background-size: cover;
                    }

                    .scrollup {
                    width: 80px;
                    height: 40px;
                    position: fixed;
                    bottom: 50px;
                    right: 100px;
                    text-indent: 0px
                    border-radius: 20px;
                    border-color:black;
                    border-style:solid;
                    border-width:1px;
                    text-align:center;
                    padding-top:10px;
                    color:black;  
                    background-color:white;
                    }
                    <script>
    $(document).ready(function () {

        $(window).scroll(function () {
            if ($(this).scrollTop() > 100) {
                $('.scrollup').fadeIn();
            } else {
                $('.scrollup').fadeOut();
            }
        });

        $('.scrollup').click(function () {
            $("html, body").animate({
                scrollTop: 0
            }, 600);
            return false;
        });

    });
    </script>


                    </style>\n<title>Smart City</title>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<script src=\"../commonfiles/sorttable.js\"></script>\n<link rel=\"stylesheet\" href=\"../commonfiles/bootstrap.css\">\n<script src=\"../commonfiles/jquery.min.js\"></script>\n<script src=\"../commonfiles/bootstrap.min.js\"></script>\n
                    
                    </head>\n<body>\n<div class=\"container\">\n<img src="../images/hdmc-logo.png" width="140em" height="140em" style="display:inline-block; margin-right:1em; margin-left:7em;">\n
    <h2 style=\"text-align:center; display:inline-block;\"><a href="../all_works/allWorks.html">Hubballi Dharwad Smart Cities Project</a></h2>\n
    <img src="../images/smartcitylogo.jpg" width="150em" height="150em" style="display:inline-block; margin-left:1em; margin-top:1.2em;">""")
      
            k.write("""<h4 style="display:inline-block;"> Total number of works: """+rowTotalstr+"""</h4>""")
            k.write("""<h4 style="display:inline-block; margin-left:3em;"> Total amount spent: &#8377 """+amtTotalstr+"""</h4>""")

      
            k.write("""
            <table class=\"table table-responsive sortable\">\n
            <thead>\n
            <tr>\n
            <th style=\"width:5%\">Sl no.</th>\n
            <th style=\"width:48%\">Work Details</th>\n
            <th>Measurement</th>\n
            <th>Unit</th>\n
            <th>Rate</th>\n
            <th>Total Amount</th>\n
            </tr>\n
            </thead>\n
            <tbody>
            <a href="#" class="scrollup">Go to top</a>
            """)

            with open(filepath, 'rU') as f:
                csvHandle = csv.reader(f)
                csvHandle.next()
                i=1
                for row in csvHandle:
                    if int(row[0]) == number:
                        
                        k.write('<tr>')

                        #serial number
                        k.write('<td class = \"span1\">' + str(i) + '</td>') 

                        #work details           
                        k.write('<td>' + row[3] + '</td>')

                        #measurement                    
                        k.write('<td>' + row[2] + '</td>')

                        #unit
                        k.write('<td>' + row[4] + '</td>')  

                        #rate
                        k.write('<td>' + row[5] + '</td>')

                        #total
                        try:
                            k.write('<td>' + str(float(row[2])*float(row[5].replace(',',''))) + '</td>')
                        except:
                            pass

                        k.write('</tr>')
                        i+=1

            k.write("</tbody>\n</table>\n</div>\n</body>\n</html>")
예제 #4
0
def workdetails(argv):

    workIDList = []
    filepath = argv[2].split('root/',
                             1)[0] + 'data/HD-works-details-2014-15.csv'
    #print filepath
    with open(filepath, 'rU') as f:
        csvHandle = csv.reader(f)
        csvHandle.next()

        for row in csvHandle:
            wid = int(row[0])
            if wid not in workIDList:
                workIDList.append(wid)

    for number in workIDList:
        rowTotal = 0
        amtTotal = 0
        with open(filepath, 'rU') as f:
            reader = csv.reader(f)
            reader.next()
            for row in reader:
                if int(row[0]) == number:
                    rowTotal += 1
                    try:
                        amtTotal = amtTotal + int(
                            float(row[2]) * float(row[5].replace(',', '')))
                    except:
                        pass

        amtTotalstr = putCommas(amtTotal)
        rowTotalstr = putCommas(rowTotal)

        with open(
                os.path.join(argv[2], 'worknum',
                             'work_' + str(number) + '.html'), 'w+') as k:
            print('Generating HTML for work ID: ' + str(number))
            #print 'Total amount: ' + amtTotalstr
            #print 'Total number of rows: ' + rowTotalstr
            k.write(
                """<!DOCTYPE html>\n<html lang=\"en\">\n<head><style>table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after {content: \" \\25B4\\25BE\"}display: inline-block;
                    width: 24px;
                    height: 24px;
                    }
                    th.sorttable_sorted::after {
                    background: url(up.png);
                    background-size: contain;
                    }
                    th.sorttable_sorted_reverse::after {
                    background: url(down.png);
                    background-size: cover;
                    }

                    .scrollup {
                    width: 80px;
                    height: 40px;
                    position: fixed;
                    bottom: 50px;
                    right: 100px;
                    text-indent: 0px
                    border-radius: 20px;
                    border-color:black;
                    border-style:solid;
                    border-width:1px;
                    text-align:center;
                    padding-top:10px;
                    color:black;  
                    background-color:white;
                    }
                    <script>
    $(document).ready(function () {

        $(window).scroll(function () {
            if ($(this).scrollTop() > 100) {
                $('.scrollup').fadeIn();
            } else {
                $('.scrollup').fadeOut();
            }
        });

        $('.scrollup').click(function () {
            $("html, body").animate({
                scrollTop: 0
            }, 600);
            return false;
        });

    });
    </script>


                    </style>\n<title>Smart City</title>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<script src=\"../commonfiles/sorttable.js\"></script>\n<link rel=\"stylesheet\" href=\"../commonfiles/bootstrap.css\">\n<script src=\"../commonfiles/jquery.min.js\"></script>\n<script src=\"../commonfiles/bootstrap.min.js\"></script>\n
                    
                    </head>\n<body>\n<div class=\"container\">\n<img src="../images/hdmc-logo.png" width="140em" height="140em" style="display:inline-block; margin-right:1em; margin-left:7em;">\n
    <h2 style=\"text-align:center; display:inline-block;\"><a href="../all_works/allWorks.html">Hubballi Dharwad Smart Cities Project</a></h2>\n
    <img src="../images/smartcitylogo.jpg" width="150em" height="150em" style="display:inline-block; margin-left:1em; margin-top:1.2em;">"""
            )

            k.write(
                """<h4 style="display:inline-block;"> Total number of works: """
                + rowTotalstr + """</h4>""")
            k.write(
                """<h4 style="display:inline-block; margin-left:3em;"> Total amount spent: &#8377 """
                + amtTotalstr + """</h4>""")

            k.write("""
            <table class=\"table table-responsive sortable\">\n
            <thead>\n
            <tr>\n
            <th style=\"width:5%\">Sl no.</th>\n
            <th style=\"width:48%\">Work Details</th>\n
            <th>Measurement</th>\n
            <th>Unit</th>\n
            <th>Rate</th>\n
            <th>Total Amount</th>\n
            </tr>\n
            </thead>\n
            <tbody>
            <a href="#" class="scrollup">Go to top</a>
            """)

            with open(filepath, 'rU') as f:
                csvHandle = csv.reader(f)
                csvHandle.next()
                i = 1
                for row in csvHandle:
                    if int(row[0]) == number:

                        k.write('<tr>')

                        #serial number
                        k.write('<td class = \"span1\">' + str(i) + '</td>')

                        #work details
                        k.write('<td>' + row[3] + '</td>')

                        #measurement
                        k.write('<td>' + row[2] + '</td>')

                        #unit
                        k.write('<td>' + row[4] + '</td>')

                        #rate
                        k.write('<td>' + row[5] + '</td>')

                        #total
                        try:
                            k.write('<td>' + str(
                                float(row[2]) *
                                float(row[5].replace(',', ''))) + '</td>')
                        except:
                            pass

                        k.write('</tr>')
                        i += 1

            k.write("</tbody>\n</table>\n</div>\n</body>\n</html>")
예제 #5
0
def allworks(argv):
  rowTotal=0
  amtTotal=0
  inprogressWorksTotal=0
  completedWorksTotal=0
  contractorsList=[]
  with open(argv[1], 'rU') as f:
        reader = csv.reader(f)
        #reader.next()
        for row in reader:
          rowTotal+=1
          amtTotal=amtTotal+int(row[14])
          if row[11] not in contractorsList:
            contractorsList.append(row[11])
          if row[17] == 'completed':
            completedWorksTotal+=1
          if row[17] == 'inprogress':
            inprogressWorksTotal+=1

        amtTotalstr=putCommas(amtTotal)
        rowTotalstr=putCommas(rowTotal)
        completedWorksTotalstr=putCommas(completedWorksTotal)
        inprogressWorksTotalstr=putCommas(inprogressWorksTotal)
        contractorsTotal=putCommas(len(contractorsList))

  with open(os.path.join(argv[2],'allworks','allworks.html'), 'w+') as k:
    k.write("""<!DOCTYPE html>\n<html lang=\"en\">\n
      <head>
      \n<title>Smart City</title>\n
      <meta charset=\"utf-8\">\n
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n
      <script src=\"../commonfiles/sorttable.js\"></script>\n
      <link rel=\"stylesheet\" href=\"../commonfiles/bootstrap.css\">\n
      <script src=\"../commonfiles/jquery.min.js\"></script>\n
      <script src=\"../commonfiles/bootstrap.min.js\"></script>\n
      <script src=\"../commonfiles/addons.js\"></script>\n
  </head>\n<body>\n<div class=\"container\">\n<img src="../images/hdmc-logo.png" width="140em" height="140em" style="display:inline-block; margin-right:1em; margin-left:7em;">\n
  <h2 style=\"text-align:center; display:inline-block;\"><a href="../allworks/allworks.html">Hubballi Dharwad Smart Cities Project</a></h2>\n
  <img src="../images/smartcitylogo.jpg" width="150em" height="150em" style="display:inline-block; margin-left:1em; margin-top:1.2em;"><div class="pull-right" style="margin-top:40px;"><a href="allworks_k.html" target="_blank">ಕನ್ನಡ</a> | <a href="allworks.html" target="_blank">English</a></div>""")
    
    k.write("""<h4 style="display:inline-block;margin-left:5em"> Total number of works: """+rowTotalstr+"""</h4>""")
    k.write("""<h4 style="display:inline-block; margin-left:7em;"> Completed works: """+completedWorksTotalstr+"""</h4>""")
    k.write("""<h4 style="display:inline-block; margin-left:7em;"> In progress works: """+inprogressWorksTotalstr+"""</h4>""")
    k.write("""<h4 style="display:inline-block; margin-left:5em;"> Total amount spent: &#8377 """+amtTotalstr+"""</h4>""")
    k.write("""<h4 style="display:inline-block; margin-left:3.5em;"> Total number of contractors: """+contractorsTotal+"""</h4>""")
    
    k.write("""
      <table class=\"table table-responsive sortable\" id="myTable" style="margin-top:2em">\n
      <thead>\n
      <tr>\n
      <th style=\"width:2%\">Ward</th>\n
      <th style=\"width:48%\">Work Description</th>\n
      <th style=\"width:10%\">Work Order Date</th>\n
      <th style=\"width:10%\">Work Completion Date</th>\n
      <th>Work Type</th>\n
      <th>Source of Income</th>\n
      <th style=\"width:7%\">Contractor</th>\n
      <th>Amount Sanctioned</th>\n
      <th>Status</th>\n
      </tr>\n
      </thead>\n
      <tbody>
      <a href="#" class="scrollup">Go to top</a>
      """) 
    rowTotal=0
    with open(sys.argv[1], 'rU') as f:
        reader = csv.reader(f)
        #reader.next()
        for row in reader:
          #print row[16]
          year=int(row[16][-2:])
          workID = row[0][:-3].replace(',','')
          workID = int(workID)
          orderDate=dateConv(row[15])
          completionDate=dateConv(row[16])
          #print (workID)
          k.write('<tr>')

          #ward number
          k.write('<td class = \"span1\"><a href=\"../wardworks/ward_'+row[1]+'.html\" target=\"_blank\">' + row[1] + '</a></td>')    
          
          #work description
          if (len(row[4])<=4):
            try:
              k.write('<td><a href=\"../worknum/work_'+str(workID)+'.html\" target=\"_blank\">' + row[24] + '</a></td>')
            except:
              pass     
          else:
            if(row[2] == '1' or row[2] == '2' or row[2] == '3'):
              k.write('<td><a href=\"../worknum/work_'+str(workID)+'.html\" target=\"_blank\">' + row[4] + '</a></td>')
            else:
              k.write('<td>'+ row[4] + '</td>')
          
          #work order date
          k.write('<td sorttable_customkey='+orderDate+'>' + row[15] + '</td>')         

          #work completion date
          k.write('<td sorttable_customkey='+completionDate+'>' + row[16] + '</td>')     

          #type of work
          k.write('<td><a href=\"../worktype/worktype_'+row[2]+'.html\" target=\"_blank\">' + row[20] + '</a></td>') 

          #source of income
          k.write('<td>' + row[19] + '</td>')   
          
          #contractor
          k.write('<td><a href=\"../contractors/contractor_'+row[12]+'.html\" target=\"_blank\">' + row[11] + '</a></td>')         
          
          #amount
          amt = int(row[14])
          amtstr=putCommas(amt)
          k.write('<td style="text-align:center;">' + amtstr + '</td>') 

          #status
          try:
            if(row[17]=="completed"):
              k.write('<td style="color:#43ac6a;">' + row[17][0].upper()+row[17][1:].lower() + '</td>') 
            else:
              k.write('<td style="color:#d32a0e;">' + row[17][0].upper()+row[17][1:].lower() + '</td>') 
          except:
            pass

          k.write('</tr>')   

          rowTotal+=1   

    k.write("</tbody>\n</table>\n</div>\n")
    k.write("</body>\n</html>")


  print("Done generating all works!") 
예제 #6
0
def allworks_k(argv):
    rowTotal = 0
    amtTotal = 0
    inprogressWorksTotal = 0
    completedWorksTotal = 0
    contractorsList = []
    with open(argv[1], 'rU') as f:
        reader = csv.reader(f)
        #reader.next()
        for row in reader:
            rowTotal += 1
            amtTotal = amtTotal + int(row[14])
            if row[11] not in contractorsList:
                contractorsList.append(row[11])
            if row[17] == 'completed':
                completedWorksTotal += 1
            if row[17] == 'inprogress':
                inprogressWorksTotal += 1

        amtTotalstr = putCommas(amtTotal)
        rowTotalstr = putCommas(rowTotal)
        completedWorksTotalstr = putCommas(completedWorksTotal)
        inprogressWorksTotalstr = putCommas(inprogressWorksTotal)
        contractorsTotal = putCommas(len(contractorsList))

    with open(os.path.join(argv[2], 'allworks', 'allworks_k.html'), 'w+') as k:
        k.write("""<!DOCTYPE html>\n<html lang=\"en\">\n
      <head>
      \n<title>Smart City</title>\n
      <meta charset=\"utf-8\">\n
      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n
      <script src=\"../commonfiles/sorttable.js\"></script>\n
      <link rel=\"stylesheet\" href=\"../commonfiles/bootstrap.css\">\n
      <script src=\"../commonfiles/jquery.min.js\"></script>\n
      <script src=\"../commonfiles/bootstrap.min.js\"></script>\n
      <script src=\"../commonfiles/addons.js\"></script>\n
  </head>\n<body>\n<div class=\"container\">\n<img src="../images/hdmc-logo.png" width="140em" height="140em" style="display:inline-block; margin-right:1em; margin-left:7em;">\n
  <h2 style=\"text-align:center; display:inline-block;\"><a href="../allworks/allworks.html">Hubballi Dharwad Smart Cities Project</a></h2>\n
  <img src="../images/smartcitylogo.jpg" width="150em" height="150em" style="display:inline-block; margin-left:1em; margin-top:1.2em;"><div class="pull-right" style="margin-top:40px;"><a href="allworks_k.html" target="_blank">ಕನ್ನಡ</a> | <a href="allworks.html" target="_blank">English</a></div> """
                )

        k.write(
            """<h4 style="display:inline-block;margin-left:5em"> Total number of works: """
            + rowTotalstr + """</h4>""")
        k.write(
            """<h4 style="display:inline-block; margin-left:7em;"> Completed works: """
            + completedWorksTotalstr + """</h4>""")
        k.write(
            """<h4 style="display:inline-block; margin-left:7em;"> In progress works: """
            + inprogressWorksTotalstr + """</h4>""")
        k.write(
            """<h4 style="display:inline-block; margin-left:5em;"> Total amount spent: &#8377 """
            + amtTotalstr + """</h4>""")
        k.write(
            """<h4 style="display:inline-block; margin-left:3.5em;"> Total number of contractors: """
            + contractorsTotal + """</h4>""")

        k.write("""
      <table class=\"table table-responsive sortable\" id="myTable" style="margin-top:2em">\n
      <thead>\n
      <tr>\n
      <th style=\"width:5%\">Ward</th>\n
      <th style=\"width:48%\">Work Description</th>\n
      <th style=\"width:10%\">Work Order Date</th>\n
      <th style=\"width:10%\">Work Completion Date</th>\n
      <th>Work Type</th>\n
      <th>Source of Income</th>\n
      <th style=\"width:7%\">Contractor</th>\n
      <th>Amount Sanctioned</th>\n
      <th>Status</th>\n
      </tr>\n
      </thead>\n
      <tbody>
      <a href="#" class="scrollup">Go to top</a>
      """)
        rowTotal = 0
        with codecs.open(sys.argv[1], 'rU', encoding='utf-8') as f:
            reader = csv.reader(f)
            #reader.next()
            for row in reader:
                #print row[16]
                year = int(row[16][-2:])
                workID = row[0][:-3].replace(',', '')
                workID = int(workID)
                orderDate = dateConv(row[15])
                completionDate = dateConv(row[16])
                #print (workID)
                k.write('<tr>')

                #ward number
                k.write('<td class = \"span1\"><a href=\"../wardworks/ward_' +
                        row[1] + '.html\" target=\"_blank\">' + row[1] +
                        '</a></td>')

                #work description
                if (len(row[4]) <= 4):
                    try:
                        k.write('<td><a href=\"../worknum/work_' +
                                str(workID) + '.html\" target=\"_blank\">' +
                                row[24] + '</a></td>')
                    except:
                        pass
                else:
                    if (row[2] == '1' or row[2] == '2' or row[2] == '3'):
                        try:
                            k.write('<td><a href=\"../worknum/work_' +
                                    str(workID) +
                                    '.html\" target=\"_blank\">' + row[24] +
                                    '</a></td>')
                        except:
                            pass
                    else:
                        try:
                            k.write('<td>' + row[24] + '</td>')
                        except:
                            pass

                #work order date
                k.write('<td sorttable_customkey=' + orderDate + '>' +
                        row[15] + '</td>')

                #work completion date
                k.write('<td sorttable_customkey=' + completionDate + '>' +
                        row[16] + '</td>')

                #type of work
                k.write('<td><a href=\"../worktype/worktype_' + row[2] +
                        '.html\" target=\"_blank\">' + row[20] + '</a></td>')

                #source of income
                k.write('<td>' + row[19] + '</td>')

                #contractor
                k.write('<td><a href=\"../contractors/contractor_' + row[12] +
                        '.html\" target=\"_blank\">' + row[11] + '</a></td>')

                #amount
                amt = int(row[14])
                amtstr = putCommas(amt)
                k.write('<td style="text-align:center;">' + amtstr + '</td>')

                #status
                try:
                    if (row[17] == "completed"):
                        k.write('<td style="color:#43ac6a;">' +
                                row[17][0].upper() + row[17][1:].lower() +
                                '</td>')
                    else:
                        k.write('<td style="color:#d32a0e;">' +
                                row[17][0].upper() + row[17][1:].lower() +
                                '</td>')
                except:
                    pass

                k.write('</tr>')

                rowTotal += 1

        k.write("</tbody>\n</table>\n</div>\n")
        k.write("</body>\n</html>")

    print("Done generating all works in Kannada!")
예제 #7
0
def index(argv,top50contractorsNamesList,top50amount):

    with open(os.path.join(argv[2],'allworks','index.html'), 'w+') as k:
        k.write("""<!DOCTYPE html>\n
            <html lang=\"en\">\n
            <head>\n
            <title>Smart City</title>\n
            <meta charset=\"utf-8\">\n
            <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n
            <script src=\"../commonfiles/sorttable.js\"></script>\n
            <link rel=\"stylesheet\" href=\"../commonfiles/bootstrap.css\">\n
            <script src=\"../commonfiles/jquery.min.js\"></script>\n
            <script src=\"../commonfiles/bootstrap.min.js\"></script>\n
            <script src=\"../commonfiles/addons.js\"></script>\n
            <script src="https://code.highcharts.com/highcharts.js"></script>
            <script src="https://code.highcharts.com/modules/exporting.js"></script>

            </head>\n<body>\n<div class=\"container\">\n<img src="../images/hdmc-logo.png" width="140em" height="140em" style="display:inline-block; margin-right:1em; margin-left:7em;">\n
            <h2 style=\"text-align:center; display:inline-block;\"><a href="../allworks/allworks.html">Hubballi Dharwad Smart Cities Project</a></h2>\n
            <img src="../images/smartcitylogo.jpg" width="150em" height="150em" style="display:inline-block; margin-left:1em; margin-top:1.2em;">
            <a href="#" class="scrollup">Go to top</a><div id="chartallworks" style="width:100%; height:600px; margin-top:5em;"></div>
            """)

        rowTotal=0
        amtTotal=0
        contractorsList=[]
        wardList=[]
        workTypeIDList=[]
        wardWorksDict={}
        wardWiseCompleted=[]
        wardWiseInprogress=[]
        wardWiseAmount=[]
        wardWiseWorksTotal=[]

        
        with open(argv[1], 'rU') as f:
            reader = csv.reader(f)
            #reader.next()
            for row in reader:
                rowTotal+=1
                amtTotal=amtTotal+int(row[14])
                if row[11] not in contractorsList:
                  contractorsList.append(row[11])
                try:
                    if int(row[1]) not in wardList:
                        wardList.append(int(row[1]))
                except:
                    pass
                if int(row[2]) not in workTypeIDList:
                    workTypeIDList.append(int(row[2]))

                amtTotalstr=putCommas(amtTotal)
                rowTotalstr=putCommas(rowTotal)
                contractorsTotal=putCommas(len(contractorsList))  

            wardList.sort()
                
            k.write("""<h4 style="display:inline-block;margin-left:5em"> Total number of works: """+rowTotalstr+"""</h4>""")
            #k.write("""<h4 style="display:inline-block; margin-left:7em;"> Completed works: """+completedWorksTotalstr+"""</h4>""")
            #k.write("""<h4 style="display:inline-block; margin-left:7em;"> In progress works: """+inprogressWorksTotalstr+"""</h4>""")
            k.write("""<h4 style="display:inline-block; margin-left:5em;"> Total amount spent: &#8377 """+amtTotalstr+"""</h4>""")
            k.write("""<h4 style="display:inline-block; margin-left:3.5em;"> Total number of contractors: """+contractorsTotal+"""</h4>""")

            k.write("""<div id="chartcontractors" style="width:100%; height:600px;"></div>""")

            k.write("""
            <table class=\"table table-responsive sortable\" id="myTable" style="margin-top:2em">\n
            <thead>\n
            <tr>\n
            <th>Ward</th>\n
            <th>In progress</th>\n
            <th> Total works</th>\n
            <th>Number of contractors</th>\n
            <th>Total amount</th>\n
            </tr>\n
            </thead>\n
            <tbody>
            """)

        for ward in wardList:
            rowTotal=0
            amtTotal=0
            completedWorksTotal=0
            inprogressWorksTotal=0
            contractorsByWardList=[]
            #reader.next()
            #print(ward)
            #print(type(ward))
            with open(argv[1], 'rU') as f:
                reader=csv.reader(f)
                #reader.next()
                for row in reader:
                    #print(row[1])
                    #print(type(row[1]))
                    if((row[1])==str(ward)):
                        rowTotal+=1
                        #print(rowTotal)
                        amtTotal=amtTotal+int(row[14])
                        if row[11] not in contractorsByWardList:
                            contractorsByWardList.append(row[11])
                        if row[17] == 'completed':
                            completedWorksTotal+=1
                        if row[17] == 'inprogress':
                            inprogressWorksTotal+=1

                amtTotalstr=putCommas(amtTotal)
                rowTotalstr=putCommas(rowTotal)
                completedWorksTotalstr=putCommas(completedWorksTotal)
                inprogressWorksTotalstr=putCommas(inprogressWorksTotal)
                contractorsTotal=putCommas(len(contractorsByWardList))



                k.write("<tr>")
                k.write("<td><a href=\"../wardworks/ward_"+row[1]+".html\" target=\"_blank\">"+str(ward)+"</a></td>")
                k.write("<td>"+inprogressWorksTotalstr+"</td>")
                k.write("<td>"+rowTotalstr+"</td>")
                k.write("<td>"+contractorsTotal+"</td>")
                k.write("<td>"+amtTotalstr+"</td>")
                k.write("</tr>")

                wardWorksDict[str(ward)]=rowTotalstr

                wardWiseAmount.append(amtTotal)
                wardWiseCompleted.append(completedWorksTotal)
                wardWiseInprogress.append(inprogressWorksTotal)
                wardWiseWorksTotal.append(rowTotal)

        k.write("</tbody>\n</table>\n")
    
        k.write("""
        <script>
        $(function () { 
        $('#chartallworks').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: 'Ward wise dashboard'
            },
            credits: {
                enabled: true
            },
            xAxis: {
                categories: """ + str(wardList) + """
            },
            yAxis: {
                title: {
                    text: 'Magnitude'
                }
            },
            series: [{
                name: 'Total works',
                data: """ + str(wardWiseWorksTotal) + """,
                visible: false
            }, {
                name: 'Completed works',
                data: """ + str(wardWiseCompleted) + """,
                visible: false
            }, {
                name: 'In progress works',
                data: """ + str(wardWiseInprogress) + """,
                
            }, {
                name: 'Total amount spent',
                data: """ + str(wardWiseAmount) + """,
                visible: false
            }]
        });
    
        $('#chartcontractors').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: 'Top 50 Contractors by Amount'
            },
            credits: {
                enabled: true
            },
            xAxis: {
                categories: """ + str(top50contractorsNamesList) + """
            },
            yAxis: {
                title: {
                    text: 'Magnitude'
                }
            },
            series: [{
                name: 'Total contract amount',
                data: """ + str(top50amount) + """,
                visible: true
            
            }]
        });
    });

    </script>""")
        k.write("</tbody>\n</table>\n</div>\n</body>\n</html>")
        k.close()
예제 #8
0
def wardworks(argv):   
    rowTotal=0 
    amtTotal=0
    contractorsList=[]
    workTypeIDList=[]
    wardList=[]
    with open(argv[1], 'rU') as f:
            reader = csv.reader(f)
            #reader.next()
            for row in reader:
                rowTotal+=1
                amtTotal=amtTotal+int(row[14])
                if row[11] not in contractorsList:
                  contractorsList.append(row[11])
                try:
                    if int(row[1]) not in wardList:
                        wardList.append(int(row[1]))
                except:
                    pass
                if int(row[2]) not in workTypeIDList:
                    workTypeIDList.append(int(row[2]))

                amtTotalstr=putCommas(amtTotal)
                rowTotalstr=putCommas(rowTotal)
                contractorsTotal=putCommas(len(contractorsList))  

            wardList.sort()

    for wardNumber in wardList:
        rowTotal=0
        amtTotal=0
        completedWorksTotal=0
        inprogressWorksTotal=0
        contractorsList=[]
        print("Generating HTML for ward " + str(wardNumber))
        with open(argv[1], 'rU') as f:
          reader = csv.reader(f)
          #reader.next()
          for row in reader:
            #print row[1]
            if((row[1])==str(wardNumber)):
                rowTotal+=1
                #print(rowTotal)
                amtTotal=amtTotal+int(row[14])
                if row[11] not in contractorsList:
                    contractorsList.append(row[11])
                if row[17] == 'completed':
                    completedWorksTotal+=1
                if row[17] == 'inprogress':
                    inprogressWorksTotal+=1

          amtTotalstr=putCommas(amtTotal)
          rowTotalstr=putCommas(rowTotal)
          completedWorksTotalstr=putCommas(completedWorksTotal)
          inprogressWorksTotalstr=putCommas(inprogressWorksTotal)
          contractorsTotal=putCommas(len(contractorsList))

        k = open(os.path.join(argv[2],'wardworks','ward_'+str(wardNumber)+'.html'), 'w+') 
        k.write("""<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n
            <title>Smart City</title>\n
            <meta charset=\"utf-8\">\n
            <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n
            <script src=\"../commonfiles/sorttable.js\"></script>\n
            <link rel=\"stylesheet\" href=\"../commonfiles/bootstrap.css\">\n
            <script src=\"../commonfiles/jquery.min.js\"></script>\n
            <script src=\"../commonfiles/bootstrap.min.js\"></script>\n
            <script src=\"../commonfiles/addons.js\"></script>\n   
            <script src="http://maps.googleapis.com/maps/api/js"></script>
            <script>
            var src = 'http://hack4hd.org/data/HD-ward-boundaries.kml';
            </script>
            <script src=\"../commonfiles/maps.js\"></script>\n
            </head>\n<body>\n<div class=\"container\">\n<img src="../images/hdmc-logo.png" width="140em" height="140em" style="display:inline-block; margin-right:1em; margin-left:7em;">\n
    <h2 style=\"text-align:center; display:inline-block;\"><a href="../allworks/allworks.html">Hubballi Dharwad Smart Cities Project</a></h2>\n
    <img src="../images/smartcitylogo.jpg" width="150em" height="150em" style="display:inline-block; margin-left:1em; margin-top:1.2em;">""")
        k.write("""<h4 style="margin-left:5em"> Ward number: """+str(wardNumber)+"""</h4>""")
        k.write("""<h4 style="display:inline-block;margin-left:5em"> Total number of works: """+rowTotalstr+"""</h4>""")
        k.write("""<h4 style="display:inline-block; margin-left:7em;"> Completed works: """+completedWorksTotalstr+"""</h4>""")
        k.write("""<h4 style="display:inline-block; margin-left:7em;"> In progress works: """+inprogressWorksTotalstr+"""</h4>""")
        k.write("""<h4 style="display:inline-block; margin-left:5em;"> Total amount spent: &#8377 """+amtTotalstr+"""</h4>""")
        k.write("""<h4 style="display:inline-block; margin-left:3.5em;"> Total number of contractors: """+contractorsTotal+"""</h4>""")
              
        k.write("""
                </div>
                <div id="googleMap" style="width:100%;height:25em;margin-top:2.5em;"></div>
                <div class="container">
                """)
          
        k.write("""
            <table class=\"table table-responsive sortable\" id="myTable">\n
            <thead>\n
            <tr>\n
            <th style=\"width:5%\">Ward</th>\n
            <th style=\"width:48%\">Work Description</th>\n
            <th style=\"width:10%\">Work Order Date</th>\n
            <th style=\"width:10%\">Work Completion Date</th>\n
            <th>Work Type</th>\n
            <th>Source of Income</th>\n
            <th style=\"width:7%\">Contractor</th>\n
            <th>Amount Sanctioned</th>\n
            <th>Status</th>\n
            </tr>\n
            </thead>\n
            <tbody>
            <a href="#" class="scrollup">Go to top</a>
            """) 

        with open(argv[1], 'rU') as f:
            reader = csv.reader(f)
            for row in reader:
                #print row[1]
                if row[1] == str(wardNumber):
                    year=int(row[16][-2:])
                    workID = row[0][:-3].replace(',','')
                    workID = int(workID)
                    orderDate=dateConv(row[15])
                    completionDate=dateConv(row[16])
                    #print (workID)
                    k.write('<tr>')

                    #ward number
                    k.write('<td class = \"span1\"><a href=\"../wardworks/ward_'+row[1]+'.html\" target=\"_blank\">' + row[1] + '</a></td>')    
                    
                    #work description
                    if (len(row[4])<=4):
                      k.write('<td>Info not available</td>')      
                    else:
                      if(row[2] == '1' or row[2] == '2' or row[2] == '3'):
                        k.write('<td><a href=\"../worknum/work_'+str(workID)+'.html\" target=\"_blank\">' + row[4] + '</a></td>')
                      else:
                        k.write('<td>'+ row[4] + '</td>')
                    
                    #work order date
                    k.write('<td sorttable_customkey='+orderDate+'>' + row[15] + '</td>')         

                    #work completion date
                    k.write('<td sorttable_customkey='+completionDate+'>' + row[16] + '</td>')     

                    #type of work
                    k.write('<td><a href=\"../worktype/worktype_'+row[2]+'.html\" target=\"_blank\">' + row[20] + '</td>') 

                    #source of income
                    k.write('<td>' + row[19] + '</td>')   
                    
                    #contractor
                    k.write('<td><a href=\"../contractors/contractor_'+row[12]+'.html\" target=\"_blank\">' + row[11] + '</a></td>')         
                    
                    #amount
                    amt = putCommas(int(row[14]))
                    k.write('<td>' + amt + '</td>') 

                    #status
                    try:
                      if(row[17]=="completed"):
                        k.write('<td style="color:#43ac6a">' + row[17][0].upper()+row[17][1:].lower() + '</td>') 
                      else:
                        k.write('<td style="color:#d32a0e">' + row[17][0].upper()+row[17][1:].lower() + '</td>')  
                    except:
                      pass

                    k.write('</tr>')   

            
        k.write("</tbody>\n</table>\n</div>\n</body>\n</html>")