# How to log bad data in an import script

**URL:** <https://meta.discourse.org/t/how-to-log-bad-data-in-an-import-script/49034>\
**Category:** Development\
**Created:** [22 أغسطس 2016، 11:41م UTC](https://meta.discourse.org/t/how-to-log-bad-data-in-an-import-script/49034 "2016-08-22T23:41:38Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [22 أغسطس 2016، 11:41م UTC](https://meta.discourse.org/t/how-to-log-bad-data-in-an-import-script/49034/1 "2016-08-22T23:41:38Z")

</div>

I’ve made considerable improvements to `mbox.rb`, the mbox email importer. I’m importing 230K messages, many of which have had the email addresses broken in one way or another. The script used to just crap out if something went wrong; I’ve added code to let the user know what file is being processed and print error messages including the bad address and the message-id when email addresses are bad and the message ID and who message when something else goes wrong.

`print_status` does a lovely job of, well, printing the status, but it’s less pretty when I `put` error messages. Also, when there are hundreds of lines of lines of such messages, having them in a terminal can be a bit unwieldy (especially if you switch sessions in `tmux` and lose the scroll-back buffer). Maybe what I should do is send stuff to stderr? Or should I just not worry?

---

_[View the full topic](https://meta.discourse.org/t/how-to-log-bad-data-in-an-import-script/49034)._
