added export csv button to export all data from the tool

This commit is contained in:
UpstreamData
2022-02-14 10:01:43 -07:00
parent d58aa871b5
commit 9bf9f8342a
3 changed files with 33 additions and 7 deletions

View File

@@ -30,6 +30,27 @@ async def import_iplist(file_location):
await update_ui_with_data("status", "")
async def export_csv(file_location, ip_list_selected):
await update_ui_with_data("status", "Exporting")
if not os.path.exists(file_location):
return
else:
if ip_list_selected is not None and not ip_list_selected == []:
async with aiofiles.open(file_location, mode='w') as file:
for item in ip_list_selected:
await file.write(str(
", ".join([str(part) for part in item])
) + "\n")
else:
async with aiofiles.open(file_location, mode='w') as file:
for item in window['ip_table'].Values:
await file.write(str(
", ".join([str(part) for part in item])
) + "\n")
await update_ui_with_data("status", "")
async def export_iplist(file_location, ip_list_selected):
await update_ui_with_data("status", "Exporting")
if not os.path.exists(file_location):