Functions of esProc/R/Python/Perl in Structured Data Process by Comparison :Chapter 5. Obtaining Field Value

esProc

=tbl.(colname)          //Return the values of a column in the table, which can be accessed by Column name

=tbl.(#4)                     //The values of a column can be accessed by Column number

=tbl(4).colname        //Return the values of Column colname of Row 4 in the table, which can be accessed by Row Number and Column Name

=tbl(4).#4                   //The values of a column or a row can be accessed by Row Number and Column Number

Perl

map(\$_[0], @result);                # Obtain the values of Column 1 in 2D array @result

\$result[3][3];             #Access to the values of Column 4 in Row 4 of 2D array @result

Where, the map is loop function; \$_ represents the current element, which is a pointer pointing to a row array; [0] indicates a reference of Member 1 to which the current element points in an array. It cannot be accessed by Column Names. The length of array doubled to take up too much memory if the associative array or structure is used.

Python

The itemgetter method that is available in operator class is very convenient. The values of a column in 2D array can be obtained by the following method:

# coding=gbk

from operator import itemgetter

data = [                               # A 2D array

[121.1, 0.02, 0.02],

[121.1, 0.05, 0.05],

[122.1, 0.56, 0.6],

[122.1, 3.79, 4.04],

[123.1, 93.75, 100.0],

[123.1, 0.01, 0.01],

[124.1, 0.01, 0.01],

[124.1, 1.01, 1.08],

[124.1, 0.11, 0.11],

[124.1, 0.05, 0.06],

[125.1, 0.39, 0.41],

]

result=[itemgetter(0,2)(i) for i in data]           # Obtain the values of Column 1 and 3

value= data[3][2]                        #Obtain the values of Row 4 and Column 3

R

tbl[I,j]                 # Values of Column j in the Row i of data frame

tbl\$sex              # Use Column Name to obtain the values of a column

tbl[,3]                 #Use Column Number to obtain the values of a column

tbl[,c(1,2,4)]     #Get the values of Columns 1, 2, 4