Skip to content

Commit 1066589

Browse files
committed
fix bug
1 parent d92f1b8 commit 1066589

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

python/graphy/utils/data_extractor.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ def write_csv(file_path: str, data: list, headers: list = None):
4040
headers = set()
4141
for row in data:
4242
headers.update(row.keys())
43-
44-
if "id" in headers:
45-
headers.remove("id") # Remove "id" if it's in the headers
46-
headers = ["id"] + sorted(
47-
list(headers)
48-
) # Add "id" to the front and sort the rest
49-
else:
50-
headers = sorted(headers) # Just sort if "id" is not present
5143
if headers:
44+
if "id" in headers:
45+
headers.remove("id") # Remove "id" if it's in the headers
46+
headers = ["id"] + sorted(
47+
list(headers)
48+
) # Add "id" to the front and sort the rest
49+
else:
50+
headers = sorted(headers) # Just sort if "id" is not present
5251
header_set = set(headers)
5352
for row in data:
5453
missing_fields = header_set - row.keys() # Find missing fields in the row

0 commit comments

Comments
 (0)