Skip to content

Add functionality for exporting documents as CSV#1

Draft
JeffersonBledsoe wants to merge 29 commits intopretagov-deployfrom
csv-export
Draft

Add functionality for exporting documents as CSV#1
JeffersonBledsoe wants to merge 29 commits intopretagov-deployfrom
csv-export

Conversation

@JeffersonBledsoe
Copy link
Copy Markdown

@JeffersonBledsoe JeffersonBledsoe commented Jun 6, 2022

Better performance but has some issues compared to #4 so leaving in draft state

@JeffersonBledsoe JeffersonBledsoe requested a review from djay June 6, 2022 09:45
def _iterate_documents(doc_ids_list):
for i, doc_id in enumerate(doc_ids_list):
if i % 2000 == 0:
transaction.abort()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Need to comment why you are doing aborts

transaction.abort()
logger.info("All documents written. Closing CSV.")

with codecs.open(export_path, "w", "utf-8") as csvfile:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why do you need write it out again from the temp file to the real file?

Comment thread Products/CMFPlomino/PlominoReplicationManager.py
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change to log debug statements


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():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@JeffersonBledsoe JeffersonBledsoe changed the base branch from searchform-fix to pretagov-deploy March 3, 2025 17:30
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