question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set_flair_csv returns "improperly formatted row, ignoring" if flair_text contains a comma.

See original GitHub issue

Test code:

import praw
r = praw.Reddit(...)
r.login(username, password)
giveflair = [{'flair_css_class': 'icedice', 'user': username, 'flair_text': 'ayy, lmao'}]
print r.get_subreddit(subreddit).set_flair_csv(giveflair)

Returns [{u'status': u'skipped', u'errors': {u'row': u'improperly formatted row, ignoring'}, u'ok': False, u'warnings': {}}]

While changing giveflair to… giveflair = [{'flair_css_class': 'icedice', 'user': username, 'flair_text': 'ayy lmao'}]

Goes through just fine. Escaping doesn’t seem to work either.

EDIT: Only tested with commas. Unsure about other symbols…

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
13steinjcommented, Jun 14, 2016

@diceroll123 , reddit uses Python’s csv reader from the standard library. If the input is, for example

>>> import csv
>>> infile = list(csv.reader(["firstpart,secondpart,whyamialive,cause,youareanidiot,ohreally"]))
>>> infile
["firstpart", "secondpart", "whyamialive", "cause", "Iareanidiot", "ohreally"]

However, the built in reader supports qouted text with precedence, so,

>>> infile = list(csv.reader(["firstpart,secondpart,whyamialive,\"cause,Iareanidiot\",ohreally"]))
>>> infile
["firstpart", "secondpart", "whyamialive", "cause,Iareanidiot", "ohreally"]

^ gets output as wanted.

So, you should be able to give a flair with a comma by doing:

...
giveflair = [{"flair_css_class": "icedice", "user": username, "flair_text": "\"ayy, lmao\""}]
...
0reactions
bboecommented, Jul 18, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found