Add functionality for exporting documents as CSV#1
Draft
JeffersonBledsoe wants to merge 29 commits intopretagov-deployfrom
Draft
Add functionality for exporting documents as CSV#1JeffersonBledsoe wants to merge 29 commits intopretagov-deployfrom
JeffersonBledsoe wants to merge 29 commits intopretagov-deployfrom
Conversation
djay
requested changes
Jun 23, 2022
| def _iterate_documents(doc_ids_list): | ||
| for i, doc_id in enumerate(doc_ids_list): | ||
| if i % 2000 == 0: | ||
| transaction.abort() |
| transaction.abort() | ||
| logger.info("All documents written. Closing CSV.") | ||
|
|
||
| with codecs.open(export_path, "w", "utf-8") as csvfile: |
There was a problem hiding this comment.
why do you need write it out again from the temp file to the real file?
| for i, doc in enumerate(_iterate_documents(doc_ids)): | ||
| for field_name in doc.getItems(): | ||
| if field_name not in column_number_field_name_mapping.itervalues(): | ||
| print("Adding field %s" % field_name) |
|
|
||
| for i, doc in enumerate(_iterate_documents(doc_ids)): | ||
| for field_name in doc.getItems(): | ||
| if field_name not in column_number_field_name_mapping.itervalues(): |
There was a problem hiding this comment.
how does checking for an id in an iterator work? don't you want to have map for fieldname -> col? That would seem more efficient.
3b5e1a7 to
6cda5e2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Better performance but has some issues compared to #4 so leaving in draft state