Hi
I can get a URL for a error report. the url likes this
https://domain/files/userid/errors2018-10-13+04%3A34%3A03+UTC20181013-17095-16eso8l.csv
How can I read this csv in python. Can I use request too?
thanks
li
These error reports? Error Reports - Canvas LMS REST API Documentation
What process is generating this file, or where is the error report coming from?
Hi Robert,
i use this https://domain/api/v1/accounts/account_id/sis_imports
from there I can find 'url' for downloading the report , for example, the url can be
https://domain/files/userid/download?11330000005243390_processing_warnings_and_errors2018-10-13+04%3A34%3A03+UTC20181013-17095-16eso8l.csv
I want to open this csv, and read data from it.
I use python. Hope this helps
julielkz, I'm not certain, but I don't think you can read the file without first downloading it.
You should be able to do that like this, including your token as carroll-ccsd indicated:
auth_header <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'Authorization'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'Bearer {}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>token<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">}</SPAN><BR />content <SPAN class="operator token">=</SPAN> requests<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>file_url<SPAN class="punctuation token">,</SPAN> headers<SPAN class="operator token">=</SPAN>auth_header<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>content<BR /><SPAN class="keyword token">with</SPAN> open<SPAN class="punctuation token">(</SPAN>output_file_name<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'wb'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> file<SPAN class="punctuation token">:</SPAN><BR /> file<SPAN class="punctuation token">.</SPAN>write<SPAN class="punctuation token">(</SPAN>content<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I was able to read the report CSVs without saving them to a file. Here's what I did:
<SPAN class="keyword token">import</SPAN> csv<BR /><SPAN class="keyword token">import</SPAN> io<BR /><BR /><SPAN class="keyword token">import</SPAN> requests<BR /><BR /><BR /><SPAN class="comment token"># Assuming you already got the download link from somewhere else</SPAN><BR />download_link <SPAN class="operator token">=</SPAN> <SPAN class="string token">'asdf'</SPAN><BR /><BR /><SPAN class="comment token"># The download link saves the CSV into memory</SPAN><BR />response <SPAN class="operator token">=</SPAN> requests<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>url<SPAN class="operator token">=</SPAN>download_link<SPAN class="punctuation token">)</SPAN><BR /><SPAN class="comment token"># Raise errors if any occurred</SPAN><BR />response<SPAN class="punctuation token">.</SPAN>raise_for_status<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><BR /><BR /><SPAN class="comment token"># Use StringIO to process the CSV contents since we're not working with a file</SPAN><BR /><SPAN class="comment token"># Cast the DictReader as a list so you can iterate over it more than once</SPAN><BR />data <SPAN class="operator token">=</SPAN> list<SPAN class="punctuation token">(</SPAN>csv<SPAN class="punctuation token">.</SPAN>DictReader<SPAN class="punctuation token">(</SPAN>io<SPAN class="punctuation token">.</SPAN>StringIO<SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">.</SPAN>text<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
At a technical level, if a user exists in two separate Canvas instances, is this a problem a Canvas Trust can address? If so, how? Can you add a trust(ed) login to an existing user account? Most of the (very limited) documentation I've found seems to focus on Trusts operating with enrollments, not users, but it does seem…
Hi everyone, I am seeking some insight into how Canvas LMS handles HTTP errors and how they are reflected in the logs versus the user interface. We are currently observing the following behavior in our environment: Log-only errors: We are seeing 500 (Internal Server Error) and 503 (Service Unavailable) errors recorded in…
I looked through the LTI Variable Substitutions documentation and while there are variable substitutions available for Canvas.term.name and Canvas.term.id (which is the Canvas incremented ID like "104"), I was surprised to see there was no option for Canvas.term.sisSourceId I tried testing other possible variants that may…
Summary:The Learning Mastery Gradebook allows drag-and-drop reordering of outcome columns, and this triggers a call to /api/v1/courses/:course_id/assign_outcome_order. The API returns 204 No Content (success), but the column order does not persist after page refresh. Steps to Reproduce: Open Learning Mastery Gradebook for…
I'm building a tool for my institution that imports grades from another LTI tool into Canvas so instructors can automate late assignment policies not otherwise supported by Canvas. I'm trying to use the LTIv1.3 ID which is readily available on the LTI-side as a link to the student record on Canvas, but I can't find the ID…