如何解析CITY ST ZIP +/- 4 [英] How to parse CITY ST ZIP+/-4

查看:179
本文介绍了如何解析CITY ST ZIP +/- 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个字段中看到了一堆你看到的内容

名为CSZ。我想以最简单的方式解析

。我只是不知道从哪里开始...


CSZ

安克雷奇AK 99518-3051

安克雷奇AK 99518 -3051

朱诺AK 99801-6917

Palmer AK 99645

Kenai AK 99611-1753

费尔班克斯AK 99709 -5008

Ketchikan AK 99901-1291

Smiths Station AL 36877-3700

佛罗伦萨AL 35631-0419

Gadsden AL 35901-3006

Huntsville AL 35805-4106

Scottsboro AL 35768-0130

Albertville AL 35950-1775


一些城市名称由2个单词组成。

所有州都是2-char缩写。一些拉链

是5位数,而其他是ZIP + 4。任何想法???

I have a bunch of what you see below in a field
named CSZ. I want to parse it the easiest way
possible. I just don''t know where to start...

CSZ
Anchorage AK 99518-3051
Anchorage AK 99518-3051
Juneau AK 99801-6917
Palmer AK 99645
Kenai AK 99611-1753
Fairbanks AK 99709-5008
Ketchikan AK 99901-1291
Smiths Station AL 36877-3700
Florence AL 35631-0419
Gadsden AL 35901-3006
Huntsville AL 35805-4106
Scottsboro AL 35768-0130
Albertville AL 35950-1775

Some city names are comprised of 2 words.
All states are 2-char abbreviations. Some zips
are 5-digit while others are ZIP+4. Any ideas???

推荐答案

MLH写道:
MLH wrote:
一些城市名称由2个单词组成。
所有州都是2-char缩写。一些拉链
是5位数,而其他拉链是ZIP + 4。任何想法???
Some city names are comprised of 2 words.
All states are 2-char abbreviations. Some zips
are 5-digit while others are ZIP+4. Any ideas???




这是一次性的事吗?如果是这样,我会将文本导入excel

文件,清理它然后导入Access。


如果它是常规的你需要做的任务,我要做的第一件事就是

联系谁无论是谁为你制作这个并且要求它作为

制表符分隔文本文件或Excel或其他东西。


如果你必须如你所描述的那样定期,也就是说,你没办法

得到来源以遵守上述要求,然后我会告诉他们

工作我很头疼我会回家玩视频游戏(或在我的

case开发Access应用程序以获得乐趣)。说真的,我可能会这样做,

但是我真的需要坐下来思考它。

-

Tim < a rel =nofollowhref =http://www.ucs.mun.ca/~tmarshal/target =_ blank> http://www.ucs.mun.ca/~tmarshal/

^ o<

/#)Burp-beep,burp-beep,burp-beep? - Quaker Jake

/ ^^Whatcha doin? - 同上TIM-MAY !! - 我



Is this a one time thing? If so, I''d import the text into an excel
file, clean it up and then import into Access.

If it''s a regular task you need to do, one of the first things I''d do is
contact whoever/whatever is producing this for you and ask for it as a
tab delimited text file or Excel or something.

If you must do it as you describe, regularly, ie, there''s no way you can
get the source to comply with the above request, then I''d tell em at
work I have a headache and I''d go home and play video games (or in my
case develop Access apps for fun). Seriously, I could probably do it,
but I''d really need to sit and think about it.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me


周三,2005年9月7日11:47:34 -0400 schrieb MLH:
Am Wed, 07 Sep 2005 11:47:34 -0400 schrieb MLH:
我有一堆你在下面的一个名为CSZ的领域看到了什么。我想以最简单的方式解析
可能。我只是不知道从哪里开始...

CSZ
安克雷奇AK 99518-3051
安克雷奇AK 99518-3051
朱诺AK 99801-6917 < />帕尔默AK 99645
Kenai AK 99611-1753
费尔班克斯AK 99709-5008
凯奇坎AK 99901-1291
史密斯站AL 36877-3700
佛罗伦萨AL 35631 -0419
Gadsden AL 35901-3006
Huntsville AL 35805-4106
Scottsboro AL 35768-0130
Albertville AL 35950-1775

一些城市名称是由2个单词组成。
所有州都是2-char缩写。一些拉链
是5位数,而其他拉链是ZIP + 4。任何想法???
I have a bunch of what you see below in a field
named CSZ. I want to parse it the easiest way
possible. I just don''t know where to start...

CSZ
Anchorage AK 99518-3051
Anchorage AK 99518-3051
Juneau AK 99801-6917
Palmer AK 99645
Kenai AK 99611-1753
Fairbanks AK 99709-5008
Ketchikan AK 99901-1291
Smiths Station AL 36877-3700
Florence AL 35631-0419
Gadsden AL 35901-3006
Huntsville AL 35805-4106
Scottsboro AL 35768-0130
Albertville AL 35950-1775

Some city names are comprised of 2 words.
All states are 2-char abbreviations. Some zips
are 5-digit while others are ZIP+4. Any ideas???




您好,


如果您无法将其作为{tab}分隔字段获取

我会从右侧解析它。

可能带有以下代码


lenghtoffield = len(csz)

strcsz = trim(csz)

''从csz右侧搜索第一个空白

''左边2个字符到n-1是状态

''从n-3左边必须是城市

为n = legthoffield为0步-1

如果是mid(strcsz,n,1)=" "然后''空白

strzip = mid(strcsz,n + 1)

strcsz = left(strcsz,n-1)

退出

endif

next

如果n< = 0则''测试是否有效拉链

msgbox 不是有效字符串

''也许你可以在这里做一些错误处理

else

strstate = mid(strcsz,n-3 )

strcity = left(strcsz,n-4)

endif


''处理代码

''strzip =来自csz的拉链

''strstate =来自csz的州

''strcity =来自csz的城市


既然你已经为每个记录做了这个,这个程序不是很快。

我也没有测试过它。


HTH

Karpi

< fluctat nec mergitur>



Hello,

if you couldn''t get it as {tab} delimited field then
I would parse it form the right side.
maybe with the following code

lenghtoffield=len(csz)
strcsz=trim(csz)
''Search for the first blank from the right side of csz
''If the first blank is found then these rules apply
''2 characters to the left to n-1 is the state
''left from n-3 must be the city
for n=legthoffield to 0 step -1
if mid(strcsz,n,1)=" " then ''blank
strzip=mid(strcsz,n+1)
strcsz=left(strcsz,n-1)
exit for
endif
next
if n<=0 then ''test if there is a valid zip
msgbox "Not a valid string"
''Maybe you can do some errorhandling here
else
strstate=mid(strcsz,n-3)
strcity=left(strcsz,n-4)
endif

''Code for handling
''strzip = Zip from csz
''strstate = State from csz
''strcity = City from csz

Since you have todo this for every record this procedure isn''t
very fast.
Also I didn''t test it.

HTH
Karpi
<fluctuat nec mergitur>


是的,它的1 - 时间的事情。我明白了。我可能会这么做。

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Yeah, its a 1-time thing. I gotcha. I may just do it the hard way.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

这是一次性的事吗?如果是这样,我会将文本导入excel
文件,清理它然后导入Access。

如果这是一项常规任务,你需要做一个我要做的第一件事是
联系谁,无论是谁为你制作这个,并将其作为
制表符分隔的文本文件或Excel或其他东西。

如果你必须定期按照你的描述去做,也就是说,你无法让源头符合上述要求,然后我会告诉他们工作我有一个头疼,我会回家玩电子游戏(或者在我的案例中开发Access应用程序以获得乐趣)。说真的,我可能会这样做,
但我真的需要坐下来思考它。

Is this a one time thing? If so, I''d import the text into an excel
file, clean it up and then import into Access.

If it''s a regular task you need to do, one of the first things I''d do is
contact whoever/whatever is producing this for you and ask for it as a
tab delimited text file or Excel or something.

If you must do it as you describe, regularly, ie, there''s no way you can
get the source to comply with the above request, then I''d tell em at
work I have a headache and I''d go home and play video games (or in my
case develop Access apps for fun). Seriously, I could probably do it,
but I''d really need to sit and think about it.






这篇关于如何解析CITY ST ZIP +/- 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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