Reputation: 15
I am trying to extract my bank balance number from an email into Google Spreadsheets. So far I have a Google script grabbing the email, then pasting it into a Google spreadsheet in rawcontent form. You can see below the RawContent that is being pasted. (This is not my bank balance or card it is a template that has been used and taken off my bank's website for a draft of what the email would look like.)
MIME-Version: 1.0
Received: by 10.79.112.196 with HTTP; Tue, 20 Oct 2015 18:13:30 -0700 (PDT)
Date: Wed, 21 Oct 2015 02:13:30 +0100
Delivered-To: [email protected]
Message-ID: <CAL9nrMo3OXzMsPUMpXjOO1AEg_u72czoYLEQLeWz [email protected]>
Subject: BB TEST
From: Liam Nagle <[email protected]>
To: Liam Nagle <[email protected]>
Content-Type: multipart/alternative; boundary=001a114d944e1c2fac052293164b
--001a114d944e1c2fac052293164b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Dear Mr. Broe,
Your weekly account summary for
account ending 6920 is below:
Current Balance as at 12:30 26 Sep:
=C2=A32500.00+
Available Balance as at 12:30 26 Sep:
=C2=A32700.00+
RECENT TRANSACTIONS:
25Sep Transfer =C2=A310.59-
25Sep Cheque deposit 150.00+
24Sep Direct Debit =C2=A33.60-
23Sep Standing order =C2=A323.50-
21Sep CC payment =C2=A349.00-
Regards,
Santander Alerts
--001a114d944e1c2fac052293164b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span style=3D"color:rgb(102,102,102);font-family:Verdana,=
Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-=
height:17.9952px">Dear Mr. Broe,</span><br style=3D"margin:0px;color:rgb(10=
2,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px=
;letter-spacing:-0.1104px;line-height:17.9952px"><br style=3D"margin:0px;co=
lor:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-si=
ze:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"><span style=3D"c=
olor:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-s=
ize:11.04px;letter-spacing:-0.1104px;line-height:17.9952px">Your weekly acc=
ount summary for</span><br style=3D"margin:0px;color:rgb(102,102,102);font-=
family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:=
-0.1104px;line-height:17.9952px"><span style=3D"color:rgb(102,102,102);font=
-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing=
:-0.1104px;line-height:17.9952px">account ending 6920 is below:</span><br s=
tyle=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helveti=
ca,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.995=
2px"><br style=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Ari=
al,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-hei=
ght:17.9952px"><span style=3D"color:rgb(102,102,102);font-family:Verdana,Ar=
ial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-he=
ight:17.9952px">Current Balance as at 12:30 26 Sep:=C2=A0</span><br style=
=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,s=
ans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"=
><span style=3D"color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,=
sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px=
">=C2=A32500.00+</span><br style=3D"margin:0px;color:rgb(102,102,102);font-=
family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:=
-0.1104px;line-height:17.9952px"><span style=3D"color:rgb(102,102,102);font=
-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing=
:-0.1104px;line-height:17.9952px">Available Balance as at 12:30 26 Sep:=C2=
=A0</span><br style=3D"margin:0px;color:rgb(102,102,102);font-family:Verdan=
a,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;lin=
e-height:17.9952px"><span style=3D"color:rgb(102,102,102);font-family:Verda=
na,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;li=
ne-height:17.9952px">=C2=A32700.00+</span><br style=3D"margin:0px;color:rgb=
(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.0=
4px;letter-spacing:-0.1104px;line-height:17.9952px"><br style=3D"margin:0px=
;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font=
-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"><span style=
=3D"color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;f=
ont-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px">RECENT TRA=
NSACTIONS:</span><br style=3D"margin:0px;color:rgb(102,102,102);font-family=
:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.110=
4px;line-height:17.9952px"><span style=3D"color:rgb(102,102,102);font-famil=
y:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.11=
04px;line-height:17.9952px">25Sep Transfer =C2=A310.59-</span><br style=3D"=
margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-=
serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"><sp=
an style=3D"color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans=
-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px">25=
Sep Cheque deposit 150.00+</span><br style=3D"margin:0px;color:rgb(102,102,=
102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;lette=
r-spacing:-0.1104px;line-height:17.9952px"><span style=3D"color:rgb(102,102=
,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;lett=
er-spacing:-0.1104px;line-height:17.9952px">24Sep Direct Debit =C2=A33.60-<=
/span><br style=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Ar=
ial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-he=
ight:17.9952px"><span style=3D"color:rgb(102,102,102);font-family:Verdana,A=
rial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-h=
eight:17.9952px">23Sep Standing order =C2=A323.50-</span><br style=3D"margi=
n:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif=
;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"><span st=
yle=3D"color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-seri=
f;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px">21Sep C=
C payment =C2=A349.00-</span><br style=3D"margin:0px;color:rgb(102,102,102)=
;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-sp=
acing:-0.1104px;line-height:17.9952px"><br style=3D"margin:0px;color:rgb(10=
2,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px=
;letter-spacing:-0.1104px;line-height:17.9952px"><span style=3D"color:rgb(1=
02,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04p=
x;letter-spacing:-0.1104px;line-height:17.9952px">Regards,</span><br style=
=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,s=
ans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"=
><br style=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,H=
elvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:=
17.9952px"><span style=3D"color:rgb(102,102,102);font-family:Verdana,Arial,=
Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height=
:17.9952px">Santander Alerts</span></div>
--001a114d944e1c2fac052293164b--
What I am hoping to get out of this is where it says:
Current Balance as at 12:30 26 Sep:
=C2=A32500.00+
Available Balance as at 12:30 26 Sep:
=C2=A32700.00+
From here i would like to extract the numbers 2500.00
and 2700.00
. The =C2=A3
part is denoting a £
written in RawContent form. After extracting the two numbers I am hoping to assign these to two cells on another sheet to then use that data to work out financial plans etc.
Upvotes: 1
Views: 96
Reputation: 10776
You can use the formula =REGEXEXTRACT(E4,"=C2=A3(\d+\.\d{2})\+")
to get the first match but the second will be a bit trickier.
Since you are already using a script I would write another quick function to extract those values.
function getBalance(){
var data = SpreadsheetApp.getActiveSheet().getRange(1,1).getValue();
var re = /=C2=A3(\d+\.\d{2})\+/g;
var results = [re.exec(data)[1], re.exec(data)[1]];
return results;
}
This will get the text, extract the two available balances by identifying them with the raw £ prefix and return them in an array.
You can then even run =GETBALANCE()
from the spreadsheet and it will give you the balances as output in two separate rows.
Upvotes: 1