title: Storing Pandas warnings I encounter in a variable
body: <p>I'm trying to read a csv file via Pandas. The dataset has 12 columns but a handful of entries end up having up to 16 columns because the fields with long texts get parsed wrong and spill over to the next columns, thereby pushing the next fields to the adjacent columns.</p>
  
  <p>These handful of entries are skipped when I set error_bad_lines as False.</p>
  
  <pre><code>assets = pd.read_csv(path + r"\employment_assets.csv", error_bad_lines=False)
  </code></pre>
  
  <p>However, I'd like to keep as much data as possible so I plan to actually correct these entries myself. Having "error_bad_lines" in the code puts out the following warnings:</p>
  
  <pre><code>"Skipping line 139: expected 11 fields, saw 12"
  "Skipping line 293: expected 11 fields, saw 16"
  "Skipping line 294: expected 11 fields, saw 15...
  </code></pre>
  
  <p>So what I'm thinking is to catch these warnings, grab the lines with errors (130, 293, etc.), and run a function on the csv itself to correct them.</p>
  
  <p>My question then is, is it possible to store Pandas (or generally Python) warnings that I encounter as a string in a variable?</p>