mysqlruby-on-railsrubyruby-on-rails-4mbox

Need help to parse mbox file and store certain attributes into MySQL database?


I have an mbox file containing my gmail messages. I would like to parse the file and import certain attributes and its values into my mysql database. Is there a way to do this? Need some suggestions.

Thank you


Solution

  • The "mbox format" is essentially a bunch of email messages concatenated together. If Ruby doesn't have a library for parsing the format, you can parse it manually by simply splitting the file on each line starting with the word "From ", then undoing any "From "-quoting within each message. This will leave you with a collection of emails.

    Parsing emails is left as an exercise for the student.