如何按组拆分多个记录文件 [英] How to split a multiple record file by groups

查看:80
本文介绍了如何按组拆分多个记录文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个记录的文本文件,每个记录的长度为1288字节.每条记录都由一个特殊的5字节代码@ 647唯一标识.

我正在从每个记录的不同字段中提取信息,但是现在我必须按@ 647指示的记录组来分隔结果.

即:

I have a text file that contains multiple records, each record is 1288 bytes in length. Each record is uniquely identified with a special 5 byte code @647.

I am pulling info from different fields in each record, but now I must separate results by the GROUP of records indicated by what''s @647.

i.e.:

20120614  12345 Joe Somebody             ...@647 = 1234500000
20120614  65497 Joe's Sister             ...@647 = 1234500000
20120614  89845 Alan Somebody            ...@647 = 5432100000
20120614  56498 Alan's Sister            ...@647 = 5432100000



我想将所有12345个记录分组到一个位置,然后将所有54321个记录分组到另一个位置.



I want to pull and group all the 12345 records in one place and then group all the 54321 records in another place.

How to I do that in vb6?

推荐答案

在这种情况下,我倾向于做的第一件事就是将传入的记录解析成更有用的东西, xml,如果不会太多的话,或者是Access或SQL

这样,您可以更轻松地搜索/查找它们

使用 RegEx [
The first thing I''d be inclined to do in situations like this is parse the incoming records into something more useful, xml, if there aren''t going to be too many of them, or Access or SQL

That way, you can search/seek over them much easier

Parse them with a RegEx[^], for example, then create an xml doc say ..

<file>
<record num="20120614"" serial="12345" name="Joe Somebody" special="@647" other="12345000" />
...
...
</file>



然后,您可以使用
[ [



Then you can use XML and XMLPath[^] to search

In this instance it would be something like \\record[@special=''@647'']

Just noticed you''re using VB6, so those two links are this[^], and this[^], respectively


这篇关于如何按组拆分多个记录文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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