13.07.2015 Views

Download pdf guide - VSN International

Download pdf guide - VSN International

Download pdf guide - VSN International

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.3 Reading data from spreadsheet files 41As with text files, it is easiest to read data from anExcel file if the data values are arranged in columnswith the identifier for each column in the first row.As an example, Figure 4.1 shows part of the fileSulphur.xls in the Data folder. This has fourcolumns, with identifiers Sulphur, Windsp,Winddir and Rain. The exclamation marks afterthe names of Winddir and Rain tell IMPORT thatthese must be formed into factors.As the file contains all the information necessaryto define what data structures are to be read, thecommand is very simple. We need supply only thefile name, using the first parameter (FILE). So thecommand isFigure 4.1IMPORT 'C:/Program files/Gen15ed/Data/Sulphur.xls'By default IMPORT prints a "catalogue" of the data structures that have been read, shownbelow. You can suppress this by setting option PRINT=*.Loading Spreadsheet FileCatalogue of file C:\USERS\ROGER\APPDATA\LOCAL\TEMP\GENSTAT\G150DD304.GWBSheet Title: Sheet1Description: Data read from d:\Program Files Gen15ed\Data\Sulphur.xls [GENSTATDATA]A2:D115Sheet Type: vectorIndex1TypevariateNval Name114 Sulphur2 variate 114 Windsp3 factor 114 Winddir4 factor 114 RainThis shows that IMPORT has read the data by first forming a temporary GenStatspreadsheet file, and then importing that into the server. You can save the GenStatspreadsheet by supplying a name (and path) for the file, using the OUTFILE option. Youcould also set the option METHOD=create, if you want to form the GenStat spreadsheetwithout then reading the data into the server.Notice that IMPORT has automatically detected the range of cells that contain the datavalues. It can do this in Sulphur.xls as all the other cells are empty. In morecomplicated situations, you can use the CELLRANGE parameter to define the range ofcells. This is specified in a string using the standard Excel conventions. InSulphur.xls the top-left cell is A1, and the bottom-right cell is D115. So we wouldhave put CELLRANGE='A1:D115'.As in SPLOAD, the SHEETNAME parameter specifies which sheet to read if the file hasmore than one, and the ISAVE parameter can again be set to a pointer to save theidentifiers of the data structures that have been read.If the identifiers are not in the file, you must set option IMETHOD=supply, and set theCOLUMN parameter to a text containing the names. You can put an exclamation mark atthe end of a name, as before, if you want the column to be formed into a factor. You canalso put a hash character (#) at the end if you want it to be a variate, or a dollar ($) if youwant it to be a text. In fact you can supply these final characters, on their own, to forcethe column type even if the names are in the file.So another way to read Sulphur.xls would be with the commandsTEXT [VALUES=Sulphur,Windsp,'Winddir!','Rain!'] ColsIMPORT 'C:/Program files/Gen15ed/Data/Sulphur.xls';\

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!