KML_FLASHEMBED_PROCESS_SCRIPT_CALLS

top menu

Importing and Plotting CSV Files

Importing and Plotting CSV Files

Import a query from a CSV (Comma Separated Value) formatted text file

EnSight has the ability to read queries from external ASCII text files, but the format of these files are specific to EnSight (see the User Manual, chapter 11.10). Many users have data in standard tabular formatted text files (e.g. CSV files from Excel) and may not be in a position to easily reformat this type of data. This QuickTool is designed to help, it can import data directly from CSV and similarly formatted ASCII files as EnSight queries. When the QuickTools button is clicked, the user is first prompted to select the file to open.  Once a file is selected, a dialog is opened to select importing options:

image4_2

The delimiter between columns of data can be set as well as other options. The user can control how whitespace (e.g. multiple whitespace delimiters) around the delimiter is handled and the character that is used to delineate strings.  Select the appropriate options for the file being imported and click “Ok”.  The file will be read into memory and a spreadsheet-like representation of the file is presented. In this example, we will be importing the output of the EnSight graphics performance tests (covered in more detail in a future article):

 

image5_2

Conceptually, a query has the general form ydata=f(xdata) with titles for the ‘x’ and ‘y’ axes as well as the query as a whole, five types of information: (YD)ata, (XD)ata, (YT)itle, (XT)itle, (T)itle. The dialog allows one to select sections of the spreadsheet and tag the selected cells one as of the five types using the icons or the menu options. The user must specify the ‘(YD)ata’ portion of the query and defaults are supplied for all the other options if they are not tagged. Once some cells have been selected pressing one of the icons causes them to be tagged visually with that icon. An example is shown below, with the query title, xdata and ydata tagged:

image6_2

There is no requirement that the cells be in columns.  Any rectangle of cells can be selected and they will be read as a vector, going row by row over all of the columns. In the case of the title strings, all of the text in all of the tagged cells will be concatenated and used as the title, so if a title crosses multiple columns, simply tag all of the necessary cells. Cells themselves can also be edited in the spreadsheet by clicking on them and entering new text. Following up on the previous example, the user has typed in titles for the ‘x’ and ‘y’ data vectors and tagged them:

image7_2

The green “+” button is used to actually import the tagged data into EnSight as a new query. The tagged selections in the dialog are then reset and another query may be imported from the same file if desired. If a selection of cells is tagged with a tag that has already used, all original tags of that type are removed before the new cells are tagged. The red “x” button can also be used to reset all of the current tags. Finally, the query can be plotted and adjusted as desired using the various query and plotter tool controls in EnSight:

image8_2

This is a very simple QuickTool and it makes is much easier to import query data in standard ASCII formats. The tool itself is written in Python and the complete source code is provided in $CEI_HOME/ensight82/site_preferences/user_defined_tools/QuickTools. Users are encouraged to look at how the tool works and create their own QuickTool functions.

© 2014 CEI Inc., makers of EnSight. All Rights Reserved.