Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix writing catalog csv files on Windows #235

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

mherrmann3
Copy link
Contributor

Problem: on Windows, csep.catalogs.AbstractBaseCatalog.write_ascii() interleaves every entry with an empty line, like so.:

lon,lat,mag,time_string,depth,catalog_id,event_id

-115.2228333,32.3463333,3.99,2005-01-02T20:58:48.280000,5.987,,ci10070917

-117.4448333,34.1238333,4.42,2005-01-06T14:35:27.680000,6.148,,ci14116972

Those files can also not be read by csep.load_catalog() (IndexError: list index out of range)

Solution: add newline='' to open(filename, write_string), see docs.python.org/3/library/csv (footnote) and stackoverflow.com/a/3348664

FYI: .write_json() is not affected, and there is no further occurrence in pyCSEP that needs to be fixed (b/c there is no further use of csv.DictWriter or csv.writer).

Type of change:

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have performed a self-review of my own code
  • My changes generate no new warnings

on Windows, `csep.catalogs.AbstractBaseCatalog.write_ascii()` interleaved every entry with an empty line

see also: https://stackoverflow.com/a/3348664
@pabloitu
Copy link
Collaborator

related to #237. Todo: check PR in windows/linux and create unit-test for windows.

Copy link
Collaborator

@pabloitu pabloitu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works ok for me!

@fabiolsilva fabiolsilva merged commit b0a84c0 into SCECcode:master Jul 27, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants