diff --git a/contact.xlsx b/contact.xlsx index 8f29640..217c10f 100644 Binary files a/contact.xlsx and b/contact.xlsx differ diff --git a/db/DbManager.py b/db/DbManager.py index 7106046..cc728cf 100644 --- a/db/DbManager.py +++ b/db/DbManager.py @@ -52,17 +52,23 @@ class DataManager: if __name__ == '__main__': - # Create a workbook and add a worksheet. - workbook = xlsxwriter.Workbook('sim_infos.xlsx') - worksheet = workbook.add_worksheet() + # Start from the first cell. Rows and columns are zero indexed. - row = 0 - col = 0 + sim_info_list = [] + for sim in params.firebase_store_manager.get_all_sim_infos().stream(): print(sim) sim_pojo = SimInfoPojo.from_firestore_dict(sim.to_dict()) + sim_info_list.append(sim_pojo) + row = 0 + col = 0 + # Create a workbook and add a worksheet. + workbook = xlsxwriter.Workbook('sim_infos.xlsx') + worksheet = workbook.add_worksheet() + for info in sim_info_list: # Iterate over the data and write it out row by row. - worksheet.write(row, col, sim_pojo.phone[2:len(sim_pojo.phone)]) - worksheet.write(row, col + 1, sim_pojo.ccid) + worksheet.write(row, col, info.phone[2:len(info.phone)]) + worksheet.write(row, col + 1, info.ccid) + worksheet.write(row, col + 2, info.position) row += 1 workbook.close() diff --git a/db/sim_infos.xlsx b/db/sim_infos.xlsx deleted file mode 100644 index ba5288a..0000000 Binary files a/db/sim_infos.xlsx and /dev/null differ diff --git a/pojo/SimInfoPojo.py b/pojo/SimInfoPojo.py index f38cd35..075ac0d 100644 --- a/pojo/SimInfoPojo.py +++ b/pojo/SimInfoPojo.py @@ -18,8 +18,12 @@ class SimInfoPojo: def from_firestore_dict(source): phone = source['phone'] ccid = source['ccid'] - update_at = source['update_at'] - position = source['position'] + update_at = None + if 'update_at' in source: + update_at = source['update_at'] + position = None + if 'position' in source: + position = source['position'] result = SimInfoPojo(phone=phone, ccid=ccid, update_at=update_at, position=position) result.id = id return result