@@ -100,6 +100,7 @@ def batch_retrieve(session, lcs, batch_start, writer):
100100 if root is None :
101101 return
102102 for result in root :
103+ id = result .attrib ["id" ]
103104 date = None
104105 temp = {}
105106 for attribute in result :
@@ -124,14 +125,14 @@ def batch_retrieve(session, lcs, batch_start, writer):
124125 and item .attrib ["title" ] in temp
125126 ):
126127 temp [item .attrib ["title" ]] = item .attrib ["value" ]
127- writer .writerow ([lcs ] + [date ] + list (temp .values ()))
128+ writer .writerow ([str ( id )] + [ lcs ] + [date ] + list (temp .values ()))
128129
129130
130131def record_license_data (session , lcs , total , writer ):
131132 """Retrieve all data for a license."""
132133 current_index = 0
133134 # replace total with 100 for testing purposes
134- while current_index < total :
135+ while current_index < 100 :
135136 batch_retrieve (session , lcs , current_index , writer )
136137 print (lcs + " batch starting at " + str (current_index ) + " complete." )
137138 current_index += 50
@@ -148,6 +149,7 @@ def record_all_licenses(session):
148149 writer = csv .writer (file , delimiter = "\t " )
149150 writer .writerow (
150151 [
152+ "id" ,
151153 "license" ,
152154 "modification_date" ,
153155 "Education Level" ,
@@ -160,14 +162,14 @@ def record_all_licenses(session):
160162 ]
161163 )
162164 # uncomment line below for testing
163- # record_license_data(
164- # session, license_list[0], license_count[0], writer
165- # )
166- # don't run below in testing
167- for x in range (0 , len (license_list )):
168- record_license_data (
169- session , license_list [x ], license_count [x ], writer
165+ record_license_data (
166+ session , license_list [0 ], license_count [0 ], writer
170167 )
168+ # don't run below in testing
169+ # for x in range(0, len(license_list)):
170+ # record_license_data(
171+ # session, license_list[x], license_count[x], writer
172+ # )
171173
172174
173175def test_access ():
0 commit comments