从电子邮件解析信息[已关闭](Parse information from an email [closed])
我的目标是收集来自电子邮件的信息,并删除除了一些关键信息之外的所有信息,在这种情况下是名称。
以下是收到的示例电子邮件。 我已经能够从Outlook中取出电子邮件,并将所有正文文本加载到数据网格中,但我不知道如何解析信息并检索名字和姓氏信息。
文本版本
From: Company Sent: Sunday, May 7, 2017 Eastern Time (US & Canada) To: LastName, FirstName (CompanyName) Subject: Thank you for your recent purchase. Dear FirstName LastName, Thank you for
HTML版本
<font face="Tahoma" size="2"><b>From:</b> Company<br> <b>Sent:</b> Sunday, May 7, 2017(UTC-05:00) Eastern Time (US & Canada)<br> <b>To:</b> LastName, FirstName (CompanyName)<br> <b>Subject:</b> Thank you for your recent purchase<br> <font face="Tahoma" size="2"><b>From:</b> Company<br> <b>Sent:</b> Sunday, May 7, 2017(UTC-05:00) Eastern Time (US & Canada)<br> <b>To:</b> LastName, FirstName (CompanyName)<br> <b>Subject:</b> Thank you for your recent purchase<br> </font><br> <div></div> <div> <div id="left-align-on-reply" dir="ltr"> <div id="main"> <div id="logo-row-box" style="width:95%; text-align:right; padding-top:6%; padding-bottom:6%"> <img id="imagesent" src="image.png" style="display:inline-block; height:28px; width:24px; right:0px"> </div> <table id="message-body-wrapper" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td id="message-body-left-margin" width="0"></td> <td id="message-body"> <table id="paragraphs" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="paragraph" style="padding:0 5% 18px; font:300 14px/18px 'Lucida Grande',Lucida Sans,Lucida Sans Unicode,sans-serif,Arial,Helvetica,Verdana,sans-serif; color:#333"> Dear FirstName LastName,</td> </tr>
My goal is to gather information from an email and remove everything except for some key information, in this case a name.
Below is a sample email that is received. I have been able to pull the email from Outlook and load all of the body text into a datagrid but I'm not sure how to parse through the information and retrieve the first and last name information.
Text version
From: Company Sent: Sunday, May 7, 2017 Eastern Time (US & Canada) To: LastName, FirstName (CompanyName) Subject: Thank you for your recent purchase. Dear FirstName LastName, Thank you for
HTML Version
<font face="Tahoma" size="2"><b>From:</b> Company<br> <b>Sent:</b> Sunday, May 7, 2017(UTC-05:00) Eastern Time (US & Canada)<br> <b>To:</b> LastName, FirstName (CompanyName)<br> <b>Subject:</b> Thank you for your recent purchase<br> <font face="Tahoma" size="2"><b>From:</b> Company<br> <b>Sent:</b> Sunday, May 7, 2017(UTC-05:00) Eastern Time (US & Canada)<br> <b>To:</b> LastName, FirstName (CompanyName)<br> <b>Subject:</b> Thank you for your recent purchase<br> </font><br> <div></div> <div> <div id="left-align-on-reply" dir="ltr"> <div id="main"> <div id="logo-row-box" style="width:95%; text-align:right; padding-top:6%; padding-bottom:6%"> <img id="imagesent" src="image.png" style="display:inline-block; height:28px; width:24px; right:0px"> </div> <table id="message-body-wrapper" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td id="message-body-left-margin" width="0"></td> <td id="message-body"> <table id="paragraphs" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="paragraph" style="padding:0 5% 18px; font:300 14px/18px 'Lucida Grande',Lucida Sans,Lucida Sans Unicode,sans-serif,Arial,Helvetica,Verdana,sans-serif; color:#333"> Dear FirstName LastName,</td> </tr>
原文:https://stackoverflow.com/questions/43837291
最满意答案
如果您想复制数据:
INSERT INTO newTable (col1, col2) SELECT col1, col2 FROM otherTable
如果要复制表结构:
使用
LIKE
基于另一个表的定义创建一个空表,包括原始表中定义的任何列属性和索引:CREATE TABLE new_tbl LIKE orig_tbl;
使用与原始表相同的表存储格式版本创建副本。 原始表上需要SELECT权限。
如果要复制结构和数据:
CREATE TABLE animals2 AS SELECT * FROM animals ;
如果你想复制没有数据的结构(但不是所有列):
CREATE TABLE animals2 AS SELECT animal -- only the columns you want FROM animals WHERE FALSE; -- and no data
If you wish to copy the data:
INSERT INTO newTable (col1, col2) SELECT col1, col2 FROM otherTable
If you wish to copy the table structure:
Use
LIKE
to create an empty table based on the definition of another table, including any column attributes and indexes defined in the original table:CREATE TABLE new_tbl LIKE orig_tbl;
The copy is created using the same version of the table storage format as the original table. The SELECT privilege is required on the original table.
If you want to copy the structure and the data:
CREATE TABLE animals2 AS SELECT * FROM animals ;
And if you want to copy the structure (but not all columns) without data:
CREATE TABLE animals2 AS SELECT animal -- only the columns you want FROM animals WHERE FALSE; -- and no data
相关问答
更多-
如何将数据从一个表复制到MySQL中的另一个新表?(How to copy data from one table to another new table in MySQL?)[2023-11-22]
这将做你想要的: INSERT INTO table2 (st_id,uid,changed,status,assign_status) SELECT st_id,from_uid,now(),'Pending','Assigned' FROM table1 如果要包括table1中的所有行。 否则,如果要仅添加table1的一个子集,则可以将WHERE语句添加到最后。 我希望这有帮助。 This will do what you want: INSERT INTO table2 (st_id,uid,c ... -
将数据从一列复制到另一列(位于不同的表中)(Copy data from one column to other column (which is in a different table))[2024-01-04]
在SQL Server 2008中,您可以使用多表更新如下: UPDATE tblindiantime SET tblindiantime.CountryName = contacts.BusinessCountry FROM tblindiantime JOIN contacts ON -- join condition here 您需要一个连接条件来指定应该更新哪一行。 如果目标表当前为空,则应使用INSERT: INSERT INTO tblindiantime (CountryName) SE ... -
如何在同一张表中将数据从一列复制到另一列?(How can I copy data from one column to another in the same table?)[2023-06-03]
这个怎么样 UPDATE table SET columnB = columnA 这将更新每一行。 How about this UPDATE table SET columnB = columnA; This will update every row. -
您的原始查询进行比较: UPDATE TestTable, TestTableTemp SET TestTable.Column1 = TestTableTemp.Column1 , TestTable.Column2 = TestTableTemp.Column2 WHERE TestTable.primaryKey = TestTableTemp.primaryKey 这是工作查询(我只是略微改变了你的版本): http://sqlfiddle.com/#!5/f3a19/9 UPD ...
-
您从一个表中选择记录并插入另一个表中。 正如你在同一个查询中那样,数据不会离开数据库,所以你不必将它存储在任何地方。 例: insert into SomeTable (SomeId, SomeBinaryField) select SomeId, SomeBinaryField from SomeOtherTable where SomeId = 42 You select the records from one table and insert into another. As you do it ...
-
如果您想复制数据: INSERT INTO newTable (col1, col2) SELECT col1, col2 FROM otherTable 如果要复制表结构: 使用LIKE基于另一个表的定义创建一个空表,包括原始表中定义的任何列属性和索引: CREATE TABLE new_tbl LIKE orig_tbl; 使用与原始表相同的表存储格式版本创建副本。 原始表上需要SELECT权限。 文档 如果要复制结构和数据: CREATE TABLE animals2 AS SELECT * ...
-
如何使用Jquery和PHP将行复制到MySQL中的另一个表?(How do I copy a row to another table in MySQL using Jquery and PHP?)[2022-07-16]
首先要做的是简化问题。 这不一定是jquery / php组合问题。 您可以先修改执行数据库查询的PHP代码。 您可以通过在URL中传递不同的参数来直观地测试它。 一旦你开始工作,将这个url插入你的javascript代码让它们一起工作是一件小事。 url参数可以是记录的主键。 你现在已经对它进行了硬编码$sql.= " WHERE id = 20 "; 它应该改为$sql.= " WHERE id = 20 "; 它的价值来自$ _POST The first thing to do is to sim ... -
是。 完成。 我所做的是,在SQL Server表中导入Excle数据,表中的所有列都是varchar数据类型。 问题出在excel数据,日期值,某处是NA。 所以我不得不用null替换所有那些NA值。 要检查表中的那些无效日期值,我使用了以下命令。 SELECT ISDATE(COL_NAME) AS Result SELECT ISNULL(COL_NAME) AS Result 为此,有时您还必须使用以下命令检查和设置SQL Server的日期格式, DBCC useroptions SET DA ...
-
将数据从一个表复制到另一个表,其中列数不同(copy data from one table to another where column count is different)[2023-02-24]
指定列: insert into table_2 (id, name, address) select (id, name, address) from table_1 当然, id需要是可插入的(不是生成的值),而phone_no需要允许null值(否则你必须指定默认值)。 Specify the columns: insert into table_2 (id, name, address) select (id, name, address) from table_1 Of course, the ... -
Cassandra表列的cqlsh中的COPY截断数据类型为double(COPY in cqlsh of Cassandra Table Column Truncating data type double)[2022-04-05]
cqlsh有一个选项控制浮点精度以进行格式化。 你可以在你的cqlshrc中设置它: [ui] float_precision=12 (通常〜/ .cassandra / cqlshrc) cqlsh has an option controlling float precision for formatting. You can set it in your cqlshrc: [ui] float_precision=12 (normally ~/.cassandra/cqlshrc)