CSV source data files

Top  Previous  Next

SQL File Import can use text files to import data into your table.  Plain text files are supported, as are UTF-8 and UTF-16 encoded files.  UTF-8 encoded files must begin with the byte order marker 0xEF,0xBB,0xBF.  UTF-16 encoded files must begin with the byte order marker 0xFF,0xFE.

 

This is the sample CSV file used in demo 4

 

source_text_01

 

The first line must contain the source column names, separated by commas.  Subsequent lines represent the data rows.  Each row may contain values for each of the source columns.  Values containing spaces or commas must be enclosed in double quotes.

 

If you want to upload data that is derived from other column's values, you can use dummy columns to act as a placeholder for the value.  For e.g. in demo 3, we have defined the following the CSV source file:

 

source_text_02

 

The size and contents columns do not contain any value, and will use scripts to populate values into them.  The final mapping of the columns would look like this:

 

source_text_03

The values for the size column is generated dynamically using the value from the filename column in this way:

 

source_text_04

 

and the contents column, which is used to upload the contents of the file name specified in the filename column, uses the following script:

 

source_text_05

 

The CSV file name can include wildcard characters (* or ?).  When wildcard characters are detected, SQL File Import will use the entered file name as a search pattern and look for files matching that search pattern.  The list of files is then sorted in alphabetical order, and the first file is used as the source CSV file.