Contents of a Data File or Database

DESCRIPTION:

Gets the names of all data sets, sheets, or tables in a specified data file or database.

USAGE:

contentsData(file=NULL, type="", odbcConnection="", server="", user="", password="", database="")

OPTIONAL ARGUMENTS:

file
a character string specifying the name of the data file. If the file has a known suffix (see the type argument below), S-PLUS assumes the file is of that type. This can be overridden by providing type explicitly. The file argument is not required if the data source is a relational database.
type
a character string specifying the type of data file or database. Only certain types of data files can contain multiple data sets (or sheets).
odbcConnection
a character string containing an ODBC connection string. This argument is required if type="ODBC" and is functional only in S-PLUS for Windows.
server
a character string specifying the database server when the data source is a relational database. If type="DIRECT-SQL", and you are accessing a non-default instance of SQL Server, specify server="SERVERNAME\\INSTANCE". To access the default instance, use server= "SERVERNAME".

This should be left as the empty string "" if type="DB2".

user
a character string specifying the user name when the data source is a relational database.
password
a character string specifying the user's password for accessing the database when the data source is a relational database. If type="ORACLE" and you are using Remote OS Authentication, specify password="self" and no user argument.
database
a character string specifying the database to use when the data source is a relational database. This should be left as the empty string "" if type="ORACLE".

VALUE:

a character vector or NULL if the data file is not a type that can contain multiple data sets.

DETAILS:

If the data source is a type of file that can contain multiple data sets (or sheets), then the returned value is a vector of the names of all the data sets in the file. Currently, the types of files that can contain more than one data set are: Microsoft Excel worksheet files, SAS transport files, and Microsoft Access files (Windows only). If the data source is a relational database, then this function returns the names of all tables. For a complete list of possible types see the type argument of the function.

SEE ALSO:

EXAMPLES:

# Only one data set can be exported to Excel
exportData(fuel.frame,"fuel.xls", type="EXCEL")
# expect to get "fuel"
contentsData("fuel.xls", type="EXCEL")  
# If the SAS transport file contains 3 data sets,
# expect to get:  "GLUCOSE" "IMPGLUC" "SINDEX"
contentsData("glucose_xport.tpt", type="SAS_TPT")
# Get the names of all tables in the Oracle server "ORACLEDB"
contentsData(type="oracle", user="scott", password="tiger", server="ORACLEDB")