fix: Check result list before appending. Remove the need to clean final_data

This commit is contained in:
KenF
2026-01-22 20:01:20 +08:00
parent 0614cee9b2
commit 675f0f6ef3
10 changed files with 30 additions and 30 deletions
+3 -3
View File
@@ -21,7 +21,8 @@ def printResources(region_name: str) -> list[list[str | int]]:
client = boto3.client('emr', region_name=region_name)
response = client.list_clusters()
for i in response['Clusters']:
return_data.append([i['Name'], i['Status'], i['NormalizedInstanceHours'], region_name])
if i:
return_data.append([i['Name'], i['Status'], i['NormalizedInstanceHours'], region_name])
return return_data
# Main function
@@ -38,8 +39,7 @@ def main() -> None:
region_data = future.result()
final_data.extend(region_data)
clean_data = [row for row in final_data if row]
for row in clean_data:
for row in final_data:
ws.append(row)
wb.save('aws-inventory.xlsx')