用星号解析名称和业务 [英] parsing names and businesses with asterisk

查看:66
本文介绍了用星号解析名称和业务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我正在努力解析一大堆名单和企业,但我遇到了麻烦。我想将其过滤到First,Middle和Last名称字段,如果它前面有星号,请删除星号并将其后面的所有内容输入到姓氏字段中。我在excel中做了一些轻微的成功,但在MS Access中遇到了问题。以下是数据示例:

Hello. I''m trying to parse out a large list of names and businesses I have but am running into trouble. I''d like to filter it into First, Middle and Last name fields, and if it has an asterisk in front of it, remove the asterisk and enter everything following it into the last name field. I''ve had some mild success doing this in excel but am having problems in MS Access. Here is an example of the data:

展开 | 选择 | Wrap | 行号

推荐答案

你有什么尝试远吗?


您的示例数据表明您了解到您甚至不知道您在问什么问题。我建议这将是开始的地方。


你希望在这里实施什么逻辑?我认为你很欣赏希望计算机以人类的方式识别常用的姓氏是一种绝望的希望。那么,你在想什么是你要求我们帮助你实现的逻辑?
Your example data illustrates that you understand that you don''t even know what question you''re asking. I suggest that would be the place to start.

What logic are you hoping to implement here? I assume you appreciate that hoping for a computer to recognise commonly used surnames in the way a human would is a forlorn hope. What, then, are you thinking would be the logic that you are asking us to help you to implement?


James Armstrong:

为什么这个项目?听起来很像是由CompSci教授给出的作业问题。


(我真的很邪​​恶的CompSci教授,好人,只是变异狡猾 - 这真是FORTRAN的痛苦! )。


然而,似乎大多数人都没有CompSci教授的恶魔,让我们只考虑这件事:


使用你的例子中的数据,解析将是一个痛苦。


只是一些伪/空气代码:

让我们从 *"这很简单。

拉出字符串的LEFT 1比较*如果是真的那么MID字符串从第二个位置通过长度并且你想要在姓氏字段中的所有这些 - 好吧,把它放在那里。


至于3和4。 ..在这里我找到了空格。

普通英语名字背后的逻辑是,他在领先字符串后面的第一个空格是分隔第一个和中间名或者姓的分隔符。所以,现在你有一个名字的逻辑分隔,因此LEFT通过空间(或MID到你)和东西进入名字字段。


现在在上下文中寻找第二个分离。第二次分离很可能是中间名称和姓氏之间的分离。取第一个分离和第二个分离之间的MID字符串的长度。一个字符通常是一个中间的首字母 - 把它放在那里并在第二个分离后取剩余的字符串并解析为姓氏。


但是,如示例中的第3行所示有一个以上的字符,我们将要做更多的猜测...检查更多的空格(即第4行)在这种情况下,第一个和第二个空格之间的MID字符串很可能是一个中间名 - 复合中间名不常见;然而,它们确实发生了,所以寻找另一个空间。如果找到,那么我们正在处理复合中间名。信仰的小小飞跃:由于来自Englished基础数据集的大多数复合中间名称只有一个空间,我们可以在第一个空格和第三个空格之间使用MID字符串,并将该数据推送到中间名称字段其余部分被推入姓氏领域。


现在有两件事:

你必须证明这不是家庭作业
你必须显示你的代码。

一旦完成,我会去挖掘我的旧FORTRAN代码(可能已经在火灾毁坏的盒子里) ...我希望不是,这是一段非常精彩的代码 - 它让我从中期考试中解脱出来!)并将其转换为VBA - 否则,你应该有足够的代码来编写代码。
James Armstrong:
Why for this project? Sounds a lot like a homework issue given by the Demon CompSci Profs.

(I had really evil CompSci Profs, good guys, just vary devious - and this was a real pain in FORTRAN!).

However, it seems that most people don''t have Demons for CompSci professors, let''s just think this thing thru:

Using the data in your example, the parsing will be a pain.

Just some pseudo/air code:
Lets start with the "*" that will be simple enough.
Pull the LEFT 1 of the string compare for "*" and if true then MID string from the 2nd position thru the length and as you want all of this in the last name field - well, put it there.

As for 3 and 4... here I''d locate the spaces.
Logic behind normal English based names is that he first space following the leading string is the deliminator separating between the first and either the middle or last names. SO, now you have a logical seperation for the first name thus LEFT pull thru to the space (or MID up to you) and stuff into the First name field.

Now look for a second separation within the context. A second separation will more than likely be the separation between a middle initial and the last name. Take the length of the MID string between the first separation and the second separation. A single character will normally be a middle initial - Put it there and take the remaining string following the second separation and parse to last name.

HOWEVER, as in line 3 of the example you have more than one character we''ll have to make a few more guesses... check for any more spaces (ie line 4) in which case, the MID string between the first and second spaces is highly likely to be a middle name - compound middle names are not very common; however, they do happen so look for another space. If found then we''re dealing with compound middle name. Taking a small leap of faith: as a majority of compound middle names from a Englished base data-set will have only one space we can then use the MID string between the first space and the third spaces and push that data into the middle name field with the remainder pushed into the last name field.

Now two things:
You will have to prove that this isn''t a homework assignment
You will have to show what you have for code.
Once done, I''ll go dig my old FORTRAN code out (that may have been in the box that the fire destroyed... I hope not, it was a really brilliant piece of code - it got me out of the mid-term exam!) and translate it to VBA - otherwise, you should have enough to write the code.


这篇关于用星号解析名称和业务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆