Skip to content

Conversation

@dsabo-JR
Copy link
Contributor

@dsabo-JR dsabo-JR commented Nov 7, 2016

This code adds the ability to have a delimiter in the utils.to_cs() method.

Added Tests to test without a delimiter and with different delimiters
Example:
>>> to_csv(['first', '2nd,with,commas', 'lasty'])
#>>> to_csv(['first', '2nd,with,commas', 'lasty'])

Choose a reason for hiding this comment

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

Why add a # here? Is it special syntax for Python comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had an error at one point because of that. ill fix it and re-push

writer = csv.writer(output)

# if the delimiter is set use it
if(delim):

Choose a reason for hiding this comment

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

What if you had delim=',' in the function declaration? Then you wouldn't need the if statement? I don't know if that's the same as not passing it though.

If you need to leave the if statement, I'd say remove the parentheses around delim.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had considered this but if someone passes in None it will replace the comma and the method will error

Choose a reason for hiding this comment

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

Ah, got it.

if delim :
writer = csv.writer(output, delimiter=delim)
# otherwise use the default comma delimiter
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this conditional, just set the default for delim to a comma

Copy link
Contributor

Choose a reason for hiding this comment

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

after discussion this makes sense

setup.py Outdated
install_requires=[
"janrain-python-api == 0.4.0",
"janrain-python-api",
"requests",
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be neccessary - janrain-python-api has requests as a dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted this back to the original setup.py

setup.py Outdated
],
install_requires=[
"janrain-python-api == 0.4.0",
"janrain-python-api == 0.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link

@paulo-akamai paulo-akamai left a comment

Choose a reason for hiding this comment

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

Looks good to me as well.

return json.dumps(item, **kwargs)

def to_csv(row):
def to_csv(row, delim=None):
Copy link

Choose a reason for hiding this comment

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

Why delim when you could use the whole word delimiter?

Copy link

@paulo-akamai paulo-akamai left a comment

Choose a reason for hiding this comment

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

Looks right to me. What's the procedure here? Just merge into master, and someone uploads?

Args:
row: list of items to be formatted as CSV
delim: the delimiter to use for the CSV output
Copy link
Contributor

Choose a reason for hiding this comment

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

change docs to reflect parameter name change

@ebeesonjanrain
Copy link
Contributor

not sure if there's anything in jira to do for this release, but as far as code - we just increment the version, create a source dist tarball, and then submit it to pypi

@dsabo-JR dsabo-JR merged commit 5c832a1 into master Nov 14, 2016
@dsabo-JR dsabo-JR deleted the topic/JANRAIN-5916/add-delimiter-to-csv branch November 14, 2016 20:27
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

Successfully merging this pull request may close these issues.

6 participants