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

newline = "" only works on Windows #8

Closed
torbengb opened this issue Oct 17, 2017 · 4 comments
Closed

newline = "" only works on Windows #8

torbengb opened this issue Oct 17, 2017 · 4 comments
Assignees

Comments

@torbengb
Copy link
Member

Line 111:

I've looked things up and it seems that the 'open()' call should be replaced with an 'io.open()' call instead. I believe the reason is that 'open()', on Linux, does not have the 'newline' parameter (not even in my up-to-date version '3.5.1-3'). (source, source)

Using 'io.open()' requires an import of 'io' in line 20, which in turn requires 'io' to have to be installed first using 'sudo python -m pip install unicodecsv').

But using 'io.open()' gives me all kinds of follow-up troubles, so that can't be it either. I also found sources that suggested importing 'unicodecsv' instead of 'csv' because that handles things nicer, but that too became too hairy for a Python novice as I am.

Another suggestion (and another) was to code myself out of the parameter problem while staying with the normal 'open()' but I couldn't make it work:

#    with open(new_filename, "w", newline = "") as file:
    if os.name is "nt": newlinefoo = {'newline':''}
    else: newlinefoo = {}
    with open(new_filename, "w", newlinefoo) as file:
@nocalla
Copy link
Member

nocalla commented Oct 17, 2017 via email

@torbengb
Copy link
Member Author

I am puzzled too, but my Linux installation insist that I do have version '3.5.1-3'.

@nocalla
Copy link
Member

nocalla commented Oct 17, 2017 via email

@torbengb
Copy link
Member Author

Closing this, as it appears my installation at fault, using Python 2.x when I should have used v3.
The shebang prevents this from reoccurring.

nocalla added a commit that referenced this issue Oct 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants