The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 313 Weeks Ago, 5 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
I am running Python 2.7 in command prompt.
I am keep getting an error message.
Â
C:Python27>BryanSohn.py
Traceback (most recent call last):
 File "C:Python27BryanSohn.py", line 5, in <module>
  from builtin import sorted
ImportError: No module named builtin
import csv
import copy
import operator
from token import EQUAL
from _builtin_ import sorted
Â
Â
reader = csv.reader(open('C:\\Python27\\Largest_Cities_CSV.csv'), delimiter=",")
Â
u = 'State -    Place'
x = 'Year'
y = 'Population'
z = 'Sohn - Rank'
rows_so_far = 0
c = 0
Â
pool = []
Â
pool.append ([])
Â
for row in reader:
     if rows_so_far ==0:
           rows_so_far+= 1
           header=row
    Â
     for j in range(0, 4) :
           if j==0:
                 pool.append([])
                 pool[0].append(u)
           if j==1:
                 pool[0].append(x)
           if j==2:
                 pool[0].append(y)
           if j==3:
                 pool[0].append(z)
     else:
    Â
           for i in reange(len(row)-2):
                 a = len(pool)
                 if not row ==[]:
                       if i ==0 or i>=1:
                             item = copy.deepcopy(row)
                             r     = copy.deepcopy(row)
                             for j in range (0,     4) :
                                   if item[i+2] is not '':
                                         if j==0:
                                               r[0] = item[j+1]+'     -    '+item[j]
                                               pool.append([])
                                               pool[a-1].append(r[0])
                                         if j==1:
                                               pool [a-1].append(int(header[i+2]))
                                         if j==2:
                                               if item[i+2] =='':
                                                    pool[a-1].append(int(0))
                                               else:
                                                     pool[a-1].append(int(item[i+2]))
                                         if j==3:
                                               pool[a-1].append(int(0))
     rows_so_far += 1
Â
a = len(pool)
list = pool[1:a-1]
Â
list.sort(key=lambda b: (b[1], b[2]), reverse=True)
Â
list1=[]
list1.append([])
list1[0]=pool[0]
list1[1:a-1] = list[0:a-2]
Â
mycsv = csv.writer(open('C:\\Python27\\ranadeep.csv', 'wb'))
for row in list1:
     e = list1.index(row)
     if row[1]<> c and e <> 0:
           v = 1
           c + row[1]
           row[3] = values
     else:
           if row[1] == c and e <> 0 :
                 v+=1
                 row[3] = values
     mycsv.writerow(row)
                                        Â
          Â
Â
Â
Could anyone help me with this>
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly