Epi Info™ User Guide
Command Reference
Analysis Commands: READ
Description
This command makes one or more forms the active dataset. It also removes any previously active datasets and associated defined variables and dataset-specific commands (e.g., RELATE, SORT, SELECT or IF statements).
Syntax
READ <table specification> FMT=”<file format>” UID=”<username>” PWD=”<password>” END
The <table specification> and FILESPEC are referred to in the following paragraphs:
The READ, RELATE, and MERGE commands can operate on many different types of data. Each type requires a different table specification, and some types required additional information in a file specification. Table specifications usually consist of a data type (contained in double quotes), a space, a file path (which may be enclosed in single quotes, and must be if it includes a space), a colon, and a table name.
The various file types that can be used are:
- Epi Info 7 Forms and Tables
- Microsoft Access 97-2003 and MS Access 2007
- Microsoft Excel 97-2003 and Excel 2007
- SQL Server – Server name and Database name will be required when accessing tables within an SQL Server database.
- Text Files – There are two basically different forms of text files. Both forms have only one table per file, so there is no need to specify a table. Both forms put the data for one record on a single line. The difference is in how the fields are indicated. One form, called “delimited,” uses designated characters to separate fields. The second form, shown in the fourth example, is called “fixed” because each field occupies the same positions in each line. All character positions through the last field must be accounted for even if they do not contain useful data (the command generator will automatically generate filler fields as required). Even if the first line of the file contains field names (HDR=”YES”), the names specified in field definitions will be used. The text file driver actually reads the file into the database, so changes made to the file after the READ will not be saved and changes made through Epi Info will not be saved to the text file (unless it is rewritten with the WRITE REPLACE command, which is available only in CSV format).
Examples
Example 1: If the file/form was previously accessed, you can select the table from current project. The current project is referenced in the config file.
READ {.\Projects\Sample\Sample.prj}:Oswego
Example 2: The Oswego Form is read. Unlike in example 1, the full path to the database file is specified.
READ {.\Projects\Sample\\Sample.prj}:Oswego
Example 3: If a space appears in the table name in Access, it must be enclosed in square brackets.
READ {.\Projects\Sample\MyData}:[Table Name with Spaces]
Example 4: An Excel spreadsheet is read.
READ {.\Projects\Sample\PlagueData.xls}:[Plague$]