solutionsdxb
Member
- Joined
- Mar 18, 2009
- Messages
- 8
- Programming Experience
- 1-3
Hi,
I am having a perl script through which i achieve is split or output from text file for each single ID , the output text file will contain data of that ID and the anme of the file will be ID.txt ,
so if i am having one main file containing 100 or 200 ID's and for each ID's may be 10000 or more lines i would like to have 100 or 200 files containing data for each single ID which i am able to achieve from perl but is it possible from vb.net
I am having a perl script through which i achieve is split or output from text file for each single ID , the output text file will contain data of that ID and the anme of the file will be ID.txt ,
so if i am having one main file containing 100 or 200 ID's and for each ID's may be 10000 or more lines i would like to have 100 or 200 files containing data for each single ID which i am able to achieve from perl but is it possible from vb.net
VB.NET:
open(TH,"myfile.txt")|| die print "not open1";
open(THG,">error.txt")|| die print "not open2";
open(INFO,">myfileAll.txt")|| die print "not open3";
$gt='0';
$flag=0;
$startflag=1;
$counter=0;
binmode TH;
$offset=0;
my ($data, $n, $offset);
while (($n = read TH, $data, 25) != 0)
{
if("$startflag"=='1')
{
$counter++;
if("$flag"=='1')
{
#exit();
if($data=~/^.+\n/)
{
}elsif($data=~/^\S+\n/)
{
}elsif($data=~/^\n/)
{
}else
{
#print "$loaddata";
$loaddata.="\n"
}
$flag=0;
}
$loaddata.=$data;
#exit();
if("$counter" > '15')
{
# print "\n\n\n$data";
# print "$loaddata";
#exit();
$counter=0;
$loaddata=~s/\n\n/\n/;
#$loaddata=~s/\n/\n/;
#print "$loaddata";
@rtg=split(/\n/,$loaddata);
# $rthm="$#rtg\t-$rtg[$#rtg]-\n";
$loaddata=pop(@rtg);
if($loaddata=~/\S+\t(\S+)\t\S+\t\S+\t([0-9A-Z]+)\t\S+\t.+\t.+\t.+/)
{
$flag=1;
}
$g=@rtg;
foreach $tg (@rtg)
{
if($tg=~/\S+\t(\S+)\t.+\t.+\t([0-9A-Z]+)/)
{
#print "$1\n";
if("$gt" ne "$1")
{
close(FILE);
$gt="$1";
open(FILE,">$gt.txt")|| die print "not open";
#sleep(15);
}
print FILE "$tg\n";
}else
{
#print "Error";
print THG "find $tg\t$rthm\n";
#print "$#rtg";
#exit();
}
}
#print "$#rtg";
$#rtg=-1;
#print "@rtg";
#exit();
}
=head
if($data=~/(^.*\n)(^.*)/)
{
#print "kk";
$frist=$1;
print "-$frist-";
$data=$2;
print "--$data--";
$dff=$#data;
#print "--$dff\n--";
#exit();
if($frist=~/.+\t([0-9]+)\t.+\t.+\t.+\n/)
{
print THG "$data";
if("$gt" ne "$1")
{
$gt="$1";
print THG "$gt\n";
}
#exit();
}
#$offset=$n-$offset;
$offset=$dff;
}
=cut
}
}
$loaddata=~s/\n\n/\n/;
@rtg=split(/\n/,$loaddata);
foreach $tg (@rtg)
{
if($tg=~/\S+\t(\S+)\t.+\t.+\t([0-9A-Z]+)/)
{
#print "ok$2";
if("$gt" ne "$1")
{
close(FILE);
$gt="$1";
open(FILE,">$gt.txt")|| die print "not open";
print "$gt\n";
}
print FILE "$tg\n";
}
}