-
Notifications
You must be signed in to change notification settings - Fork 37
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
csv format #2
Comments
Hi, yes, CSV would make a lot of sense, thanks! A few guidelines if you wish to contribute to this one (otherwise I could write it, but not this week):
If you have other thoughts or questions, do not hesitate to post them. Thanks! |
I'm hacking on the CSV output but being new to Python not sure about a few things. I basically copied _write_plain_text_report to _write_csv_report and have been modifying from there... I'm not sure how best to integrate with 'output_files'. I can hack up something with oprint:
But as you mentioned we should probably use the CSV module:
But it seems like I should integrate with output_file(s) somehow as that is used everywhere else. Can you offer some guidance on how I might proceed? :) |
Hi Jim, here are a few stubs to get you started. Your last snippet looks promising: # in report(...)
if config.options.format == FORMAT_PLAIN:
_write_plain_text_report(site, config, output_files, total_time)
elif config.options.format == FORMAT_CSV:
_write_csv_report(site, config, output_files, total_time)
def _write_csv_report(...):
csv_writers = [csv.writer(output_file) for output_file in output_files]
# maybe write a first row/header here
for page in pages.values():
# here we just output the result of each url
# if we want to include the source of each url, i guess we would
# need to repeat the result and the original url on each row as if we had
# denormalized/joined multiple database tables
writerow([page.get_status_message(), page.url_split.geturl()], writers=csv_writers)
def writerow(row, writers):
for writer in writers:
writer.writerow(row) |
It looks like the original author had ideas for other output formats other than plain text. I see HTML as one format in the code.
I was curious how hard it would be to add CSV? It appears I could copy _write_plain_text_report in reporter.py and tweak?
I'm tinkering with the code now and if I come up with anything will send it back.
The text was updated successfully, but these errors were encountered: