diff --git a/esxport/esxport.py b/esxport/esxport.py index bca08d9..797f6ca 100644 --- a/esxport/esxport.py +++ b/esxport/esxport.py @@ -187,7 +187,7 @@ def _extract_headers(self: Self) -> list[str]: """Extract CSV headers from the first line of the file.""" file_name = f"{self.opts.output_file}.tmp" with Path(file_name).open() as f: - first_line = json.loads(f.readline().strip("\n")) + first_line = json.loads(f.readline()) return list(first_line.keys()) def _export(self: Self) -> None: diff --git a/test/esxport/_export_test.py b/test/esxport/_export_test.py index 979060a..fe102b5 100644 --- a/test/esxport/_export_test.py +++ b/test/esxport/_export_test.py @@ -62,9 +62,6 @@ def test_headers_extraction( test_json = {"age": 2, "bar": "foo", "hello": "world"} temp_file = f"{esxport_obj.opts.output_file}.tmp" with Path(temp_file).open("w") as tmp_file: - tmp_file.write(json.dumps(test_json)) - tmp_file.write("\n") - assert Path(temp_file).exists() is True - keys = list(test_json.keys()) - assert esxport_obj._extract_headers() == keys + json.dump(test_json, tmp_file) + assert esxport_obj._extract_headers() == list(test_json.keys()) TestExport.rm_export_file(f"{inspect.stack()[0].function}.csv")