Home > database >  Why there are duplicates. How should do ability to won't have to repeat?
Why there are duplicates. How should do ability to won't have to repeat?

Time:10-05

The integer li_FileNum
String ls_file_swap
Long I, j
Li_FileNum=FileOpen (" D: \ PB production \ zuixin \ 1. TXT ", lineMode! The Write! , LockWrite! , Append!)
Dw_1. Setsort (' city, tmpname tmpadd, DHGSH, tmptel_1, what zj had, CLS, bianma, tmpname1, tmpname2, beizhu, jibie, city1, cls1, bianma1, isok, SFJD ')
//
Dw_1. Sort ()
J=dw_1 rowcount ()
If j> 0 then
Ls_file_swap=dw_1. Getitemstring (1, "city") + "" + dw_1 getitemstring (1, 'tmpname) +" "+ dw_1 getitemstring (1,' tmpadd) +" "+ dw_1 getitemstring (1, 'tmptel_1)
For I=2 to j

If dw_1. Getitemstring (I, 'tmpname')=dw_1. Getitemstring (I - 1, 'tmpname) then
//if the company name is the same, then take out the following fields
Ls_file_swap=ls_file_swap + "~ r ~ n" + dw_1. Getitemstring (I, 'DHGSH) + "" + dw_1 getitemstring (I,' tmptel_1) +" "+ string (dw_1. Getitemnumber (I, 'what zj had')) +" "+ dw_1 getitemstring (I, 'CLS) & amp;
+ "" + dw_1. Getitemstring (I, 'bianma) +" "+ dw_1 getitemstring (I,' tmpname1) +" "+ dw_1 getitemstring (I, 'tmpname2) +" "+ string (dw_1. Getitemnumber (I,' jibie ')) +" "+ dw_1 getitemstring (1, 'beizhu) & amp;
+ "" + dw_1. Getitemstring (1, 'city1) +" "+ dw_1 getitemstring (1,' cls1) +" "+ dw_1 getitemstring (1, 'bianma1) +" "+ string (dw_1. Getitemnumber (I,' Isok ')) +" "+ string (dw_1. Getitemnumber (I, 'SFJD))

The else
//if you are not the same, start a new line, take out the following fields and
Ls_file_swap=ls_file_swap + "~ r ~ n" + dw_1. Getitemstring (1, "city") + "" + dw_1 getitemstring (I, 'tmpname) +" "+ dw_1 getitemstring (I,' tmpadd) +" "+ dw_1 getitemstring (I, 'tmptel_1)
End the if
FileWrite (li_FileNum ls_file_swap)
Next
End the if

When several DHGSH repeat it a few times,

Like this. Don't know where is wrong, how can like this, prawn to help me!!!!!!!!!

XX XX township hospitals high village street 64900173
XX XX township hospitals high village street 64900173
Department of 64900203
XX XX township hospitals high village street 64900173
Department of 64900203
Clinic orthopedic 64900132
XX XX township hospitals high village street 64900173
Department of 64900203
Clinic orthopedic 64900132
Internal medicine outpatient service 64900073
Here only lists some of the columns, originally want results should be
XX XX township hospitals high village street 64900173
Department of 64900203
Clinic orthopedic 64900132
Internal medicine outpatient service 64900073
But instead, depressed,,,,,

CodePudding user response:

If compare and
Dw_1. Getitemstring (1, 'city')
There is a problem!

With a variable to hold the tmpname convenient point
String sname
J=dw_1 rorcount ()
If j> 0 then
Sname=dw_1. Object. Tmpname [1]
Ls_file_swap=dw_1. Getitemstring (1, "city") + "" + dw_1 getitemstring (1, 'tmpname) +" "+ dw_1 getitemstring (1,' tmpadd) +" "+ dw_1 getitemstring (1, 'tmptel_1)

For I=2 to j
If snam=dw_1. Object. Tmpname [I]
Ls_file_swap=ls_file_swap + "~ r ~ n" + dw_1. Getitemstring (I, 'DHGSH),,,
The else
Ls_file_swap=ls_file_swap + "~ r ~ n" + dw_1. Getitemstring (I, "city") + "" + dw_1 getitemstring (I, 'tmpname) +" "+ dw_1 getitemstring (I,' tmpadd) +" "+ dw_1 getitemstring (I, 'tmptel_1)
Snam=dw_1. Object. Tmpname [I]
Next
End the if


Debugging and see again!

CodePudding user response:

Very troublesome.
Turn the content into a data table, then according to the needs of the business, are distinct and having the count (*) & gt; 1 to go,

CodePudding user response:

Can be directly set up a group, a type of dw grouped by the first two columns
Directly when saving dw_group. Saveas (" D: \ PB production \ zuixin \ 1. TXT ", the text! , FALSE)

CodePudding user response:

To make a table, use SQL to write, easy and convenient

CodePudding user response:

Lz want?
  • Related