Eliminate extra empty lines in CSV monitor files on Windows (DLR-RM#692) (#695)

* Added ``newline="\n"`` when opening CSV monitor files so that each line ends with ``\r\n`` instead of ``\r\r\n`` on Windows while Linux environments are not affected
This commit is contained in:
hsuehch 2021-12-18 23:04:33 +09:00 committed by GitHub
parent e24147390d
commit 222a69ca49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -37,6 +37,7 @@ Others:
^^^^^^^
- Added a warning in the env checker when not using ``np.float32`` for continuous actions
- Improved test coverage and error message when checking shape of observation
- Added ``newline="\n"`` when opening CSV monitor files so that each line ends with ``\r\n`` instead of ``\r\r\n`` on Windows while Linux environments are not affected (@hsuehch)
Documentation:
^^^^^^^^^^^^^^
@ -852,4 +853,4 @@ And all the contributors:
@ShangqunYu @PierreExeter @JacopoPan @ltbd78 @tom-doerr @Atlis @liusida @09tangriro @amy12xx @juancroldan
@benblack769 @bstee615 @c-rizz @skandermoalla @MihaiAnca13 @davidblom603 @ayeright @cyprienc
@wkirgsn @AechPro @CUN-bjy @batu @IljaAvadiev @timokau @kachayev @cleversonahum
@eleurent @ac-93 @cove9988 @theDebugger811
@eleurent @ac-93 @cove9988 @theDebugger811 @hsuehch

View file

@ -178,7 +178,7 @@ class ResultsWriter:
filename = os.path.join(filename, Monitor.EXT)
else:
filename = filename + "." + Monitor.EXT
self.file_handler = open(filename, "wt")
self.file_handler = open(filename, "wt", newline="\n")
self.file_handler.write("#%s\n" % json.dumps(header))
self.logger = csv.DictWriter(self.file_handler, fieldnames=("r", "l", "t") + extra_keys)
self.logger.writeheader()