Skip to content

Update CSV reader logic to work with Python 3 #11

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

drewbrew
Copy link

@drewbrew drewbrew commented Jun 13, 2022

I think Heroku forcibly upgraded grorg to Python 3, which broke CSV loading.

Because the type of the csv_obj.csv field will be a bytes, we need to decode that into a utf-8 str before passing it into
csv.reader(). This avoids the headers being parsed incorrectly, such as the first field being named b'My Field.

This also fixes migrations to work with Python 3 and replaces __unicode__ with __str__

CSV parsing works now!
image

drewbrew added 3 commits June 13, 2022 09:25
Because the type of the `csv_obj.csv` field will be a `bytes`,
we need to decode that into a utf-8 `str` before passing it into
`csv.reader()`. This avoids the headers being parsed incorrectly,
such as the first field being named `b'My Field`.
@drewbrew drewbrew marked this pull request as ready for review June 13, 2022 14:34
@jefftriplett
Copy link

So while our branch might be too opinionated (I started with a pre-commit run on all-the-things), posting this here in case someone else finds it to be helpful https://github.com/djangocon/grorg

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.

2 participants