本文介绍了如何解析CITY ST ZIP +/- 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我在一个字段中看到了一堆你看到的内容 名为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 fieldnamed CSZ. I want to parse it the easiest waypossible. I just don''t know where to start...CSZAnchorage AK 99518-3051Anchorage AK 99518-3051Juneau AK 99801-6917Palmer AK 99645Kenai AK 99611-1753Fairbanks AK 99709-5008Ketchikan AK 99901-1291Smiths Station AL 36877-3700Florence AL 35631-0419Gadsden AL 35901-3006Huntsville AL 35805-4106Scottsboro AL 35768-0130Albertville AL 35950-1775Some city names are comprised of 2 words.All states are 2-char abbreviations. Some zipsare 5-digit while others are ZIP+4. Any ideas???推荐答案 这是一次性的事吗?如果是这样,我会将文本导入excel 文件,清理它然后导入Access。 如果它是常规的你需要做的任务,我要做的第一件事就是 联系谁无论是谁为你制作这个并且要求它作为 制表符分隔文本文件或Excel或其他东西。 如果你必须如你所描述的那样定期,也就是说,你没办法 得到来源以遵守上述要求,然后我会告诉他们 工作我很头疼我会回家玩视频游戏(或在我的 case开发Access应用程序以获得乐趣)。说真的,我可能会这样做, 但是我真的需要坐下来思考它。 - Tim 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 excelfile, 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 iscontact whoever/whatever is producing this for you and ask for it as atab delimited text file or Excel or something.If you must do it as you describe, regularly, ie, there''s no way you canget the source to comply with the above request, then I''d tell em atwork I have a headache and I''d go home and play video games (or in mycase 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 您好, 如果您无法将其作为{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 thenI would parse it form the right side.maybe with the following codelenghtoffield=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 cityfor n=legthoffield to 0 step -1if mid(strcsz,n,1)=" " then ''blankstrzip=mid(strcsz,n+1)strcsz=left(strcsz,n-1)exit forendifnextif n<=0 then ''test if there is a valid zipmsgbox "Not a valid string"''Maybe you can do some errorhandling hereelsestrstate=mid(strcsz,n-3)strcity=left(strcsz,n-4)endif''Code for handling''strzip = Zip from csz''strstate = State from csz''strcity = City from cszSince you have todo this for every record this procedure isn''tvery fast.Also I didn''t test it.HTHKarpi<fluctuat nec mergitur> 这篇关于如何解析CITY ST ZIP +/- 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-12 19:38