Functions of esProc/R/Python/Perl in Structured Data Process by Comparison:Chapter 10.Removing Record

Uncategorized 800 0

esProc

    =tbl.delete([1,3,5])           // Delete Records 1, 3 and 5

    =tbl.delete(15)                   // Delete Record 15

    =tbl.delete(tbl.pselect@a(col1>50))       //Delete any record where col1>50 is true

Perl

    my @myarray=(1,2,3,4,5,6,7,8,9,10);

    splice(@myarray,1,3);     #Subsequent three elements from the second position are removed, and then @myarray=(1,5,6,7,8,9,10),

    splice(@myarray,5,1);     # Delete Element 6

 

    my @myarray=(1,2,3,4,5,6,7,8,9,10);

    delete @myarray[1,3,5];         #Delete the elements in the positions 2, 4, 6, and subsequent elements are not be moved forward, so that the length of array remains unchanged

Some defects are:

  1. splice cannot remove more than one discontinuous elements at a time.
  2. After the element is removed by delete, the subsequent elements cannot be moved forward and the length of array remains unchanged, so that it is not completely removed.
  3. You cannot remove the element according to specific criterion, only be allowed to find the sequence number of element which matches with specific criterion, and then remove it.
  4. To find the element which matches with specific criterion will take more works, refer to the Section Find Records.

 

Python

As what Perl does, Python provides a delete function for an array, which can only be used to remove individual element or a number of continuous elements with removal by specific criterion disabled, failing to remove several discontinuous elements at a time, for example:

    del data[3:5]    #Delete the elements from Position 3 to Position 4, namely, those elements in the positions of >=3 and <5

    del data[2]        #Delete the element of Position 2, namely, Element 3

If you want to delete the array element based on specific criterion, only the sequence numbers of records which are matched with specific criterion will be available. Thenthe resulting records will be deleted one-by-one, refer to the Section Find Records

R

    tbl[-n,]                                                     #Delete Row n from tbl

    newtbl<-tbl [tbl $c1>50,]                   #As shown in the Section 7, delete the records where c1 is less than and equal to 50

FAVOR (0)
Leave a Reply
Cancel
Icon

Hi,You need to fill in the Username and Email!

  • Username (*)
  • Email (*)
  • Website