Re: Import data from an email
- To: mathgroup at smc.vnet.net
- Subject: [mg107668] Re: Import data from an email
- From: dh <dh at metrohm.com>
- Date: Mon, 22 Feb 2010 08:31:31 -0500 (EST)
- References: <hlj42f$rsc$1@smc.vnet.net>
Hi, first you have to transfer your data into mathematica. This can e.g. be don be copy/paste into a string. Or you could export the email and read it into mathematica as a string. Parsing can the be done e.g. using StringCases and Regular Expressions. Here is an example where I pasted the data into a string: s = "data indexes = {1, 3 , 6 , 7, 24 } years to evaluate = 5 startMonth = {1} startYear = {2007} "; data = StringCases[s, RegularExpression["data indexes =\s*({[\d, ]+})"] :> "$1" ][[1]]; years2Evaluate = StringCases[s, RegularExpression["years to evaluate =\s*(\\d+)"] :> "$1"][[1]]; startMonth = StringCases[s, RegularExpression["startMonth =\s*{(\\d+)}"] :> "$1"][[1]]; startYear = StringCases[s, RegularExpression["startYear =\s*{(\d+)}"] :> "$1" ][[1]]; {data, years2Evaluate, startMonth, startYear} = ToExpression@{data, years2Evaluate, startMonth, startYear} Daniel On 18.02.2010 11:16, 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 someprovider.com > Time Stamp = {2010, 02, 16, 14, 37, 22} (* DateList format*) > > I would like you automate the reading or importing of these specs into > Mathematica. > > So, > > 1. Can I identify the an email has arrived with the identifying > subject line? > 2. Can I use Import[] or Read[] or something to get the body of the > email into a notebook? > 3. How? > > Anything that can point me in the right direction will help. > > Thanks. > > > > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh at metrohm.com> Internet:<http://www.metrohm.com>