MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Import data from an email

  • To: mathgroup at
  • Subject: [mg107606] Re: Import data from an email
  • From: Bill Rowe <readnews at>
  • Date: Fri, 19 Feb 2010 03:35:09 -0500 (EST)

On 2/18/10 at 5:16 AM, warsaw95826 at (Garapata) wrote:

>I use Apple's Mail program.  I get sent emails that have test
>specifications, which I currently enter into a Mathematica notebook
>manually, I then run the specs against data collected in the field.

>The emails have a specific subject line:

>"Test specification ..."

>The spec in the body of the email looks something like this:

>data indexes = {1, 3 , 6 , 7, ..., 24 }
>years to evaluate = 5
>startMonth = {1}
>startYear = {2007}
>submitter email = user at
>Time Stamp = {2010, 02, 16, 14, 37, 22}  (* DateList format*)

>I would like you automate the reading or importing of these specs
>into Mathematica.


>1.  Can I identify the an email has arrived with the identifying
>subject line?

There are two possible approaches to locating the file with the
messages of interest. First would be to use Mathematica's
=46indList to find files containing the subject string. Second,
would be to use Applescript with Mail to have Mail save those
messages to a specific directory.

Messages are stored in a subdirectory of ~/Library/Mail. This
would be the starting point for a search done using FindList.
But, if you have a large number of emails in Mail, this means
you will be searching a large number of files for the few that
have the given subject line. This is likely to be slow and is
certainly inefficient compared to having Mail save the target
messages in an appropriate folder.

>2.  Can I use Import[] or Read[] or something to get
>the body of the email into a notebook?

I am going to assume the only places the "=" character appears
is in those lines you want to read into Mathematica. If so,

data = FindList[filename,"="];

will make data a list of those lines. Then

data = StringSplit[[#,"=]&/@data;

will transform data into a two column list (assuming only one
"=" character per line) with the first column being the data tag
and the second being the data.



will transform this into a {string, data} pair

  • Prev by Date: Re: Re: updating help
  • Next by Date: Re: Re: Re: May we trust IntegerQ
  • Previous by thread: Re: Import data from an email
  • Next by thread: Re: Import data from an email