解析地址“标签” Excel、C#、VBA 或其他字段?
有人给我发了一个 Word 文件,其中包含用制表符分隔的地址标签。请参阅
我正在尝试找出将地址导入到各个记录中的最佳方法。可能只是分别使用 NameLine、Address1、Address2(我稍后可以解析的 3 个字段)。
使用 C# 或 VBA 可以轻松做什么?还是UltraEdit?
Someone's sent me a Word file full off address labels separated by tabs. See
I'm trying to figure out the best way to import the addresses into individual records. Probably just go with NameLine, Address1, Address2 for each one (3 fields that I can parse later).
What can I do easily with C# or VBA? Or UltraEdit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我喜欢 Excel 做这样的事情。只需从 Word 复制文本,将其粘贴到 Excel 中,然后使用带有制表符分隔符的文本导入向导,确保将连续分隔符视为一个分隔符。
Excel 甚至可以为您解析它:
B1
中,创建公式=A1
。C1
中,创建公式=A2
。D1
中,创建公式=A3
。B1
到D3
,或者如果每个地址记录之间有空行,则选择D4
。B4
或B5
。CTRL+END
选择所有内容,直到数据末尾(基本上,应选择单元格B5:DXX
)结果示例:
然后,您可以将结果复制到新工作表中(没有公式,因此它只是静态文本),按照您想要的方式格式化数据,并对数据进行排序以删除那些讨厌的空白行。
I like Excel for things like this. Just copy the text from Word, paste it into Excel, and use the text import wizard with a tab delimiter, making sure to treat consecutive delimiters as one.
Excel can even parse it for you:
B1
, create formula=A1
.C1
, create formula=A2
.D1
, create formula=A3
.B1
throughD3
, orD4
if you have blank lines between each address record.B4
, orB5
if there's blank lines between each address record.CTRL+END
to select everything until the end of the data (basically, cellsB5:DXX
should be selected)Example result:
Afterwards, you can copy the results into a new worksheet (sans formulae, so it'll just be static text), format the data however you want it, and sort the data to remove those pesky blank lines.
如果所有选项卡在 Word 中对齐,您应该能够通过
Alt-Select
来选择单个列,然后剪切并删除所有选项卡。将它们粘贴到一个连续的列中,这样您就可以获得一个由Address1,Address2,Address3,BlankLine
组成的连续文件,这样解析起来就很简单了。If all the tabs line up in Word, you should be able to
Alt-Select
to select individual columns, then cut & paste them into one sequential column so you just get one contiguous file ofAddress1,Address2,Address3,BlankLine
, which should then be trivial to parse.