使用 VB.NET 比较和合并多个文件的文本文件
我有多个文本文件需要合并。但我需要在合并之前比较参考号。
下面是文本文件
Text 1
001Email
002Video
003SocialNetwork
Text 2
001Gmail
001Yahoo
002Youtube
002Metacafe
003Facebook
003Myspace
Text 3
www.gmail.com001
www.yahoo.com001
www.youtube.com002
www.myspace.com002
www.facebook.com003
www.myspace.com003
Output
001Email
001Gmail
www.gmail.com001
001Yahoo
wwww.yahoo.com001
002Video
002Youtube
www.youtube.com002
002Metacafe
www.metacafe.com002
003SocialNetwork
003Facebook
www.facebook.com003
003Myspace
www.myspace.com003
什么是最快的处理方法,逐行读取进行比较。文本文件由数千行组成
I have a multiple text files that I need to merge. but I need to compare the reference number before merge it.
below is the text file
Text 1
001Email
002Video
003SocialNetwork
Text 2
001Gmail
001Yahoo
002Youtube
002Metacafe
003Facebook
003Myspace
Text 3
www.gmail.com001
www.yahoo.com001
www.youtube.com002
www.myspace.com002
www.facebook.com003
www.myspace.com003
Output
001Email
001Gmail
www.gmail.com001
001Yahoo
wwww.yahoo.com001
002Video
002Youtube
www.youtube.com002
002Metacafe
www.metacafe.com002
003SocialNetwork
003Facebook
www.facebook.com003
003Myspace
www.myspace.com003
What will be the fastest way to deal it read line by line to compare. the text file consist of thousand of line
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是一个过于复杂的解决方案。代码中的注释应该能够解释一切。输出与您所拥有的不完全匹配,因为我不知道顺序对所有事情有多重要。它首先按参考号对所有内容进行排序,然后按字符串的文本部分(不包括
www.
)进行排序。您发布的结果按参考编号顺序排列,然后按文件解析顺序排列,然后按字母顺序排列(002Metacafe 在 002Video 之后)。让我知道这是否重要。Here's what might possibly be an overly complex solution. The comments in the code should explain everything hopefully. The output doesn't match exactly what you have because I don't know how much order is important for everything. It sorts everything first by the reference number and then by the text portion of the string (excluding
www.
). The results you posted were in reference number order and then file parsing order and then alphabetical (002Metacafe came after 002Video). Let me know if that's important.