Data: Import from File: Comma Delimited (CSV)
If you do not see this file type, choose Data: Import from File: Add/Remove File Types...
To add drag & drop support for a file type, see Import Filter Manager.
This X-Function supports file re-import. See this topic for details.
Import CSV file
impCSV fname:=system.path.program$+"Samples\Import and Export\donations.csv"; //import a csv file without open the dialog
Specify the filename of the file to be imported.
This is used to show the file size in the dialog. The information is detected by Origin automatically.
This is mainly used in the dialog, for tweaking the import options. Please see the Descriptions section for details.
Use this to specify the output range.
See the syntax here.
This is for outputting the header information. It is hidden from the GUI. Users are not advised to use this variable from Labtalk.
This is used for the reimport feature. It is hidden from the GUI. Users are not advised to use this variable from Labtalk.
CSV (comma-separated values) is one kind of delimited file, which as the name suggests, uses commas to separate values. This X-Function helps you to import this kind of file.
Details on Some Dialog Options
This example imports multiple CSV files into same worksheet. File names are put to column comments.
Partial import is done from 2nd file on, so only data from 2nd column on is imported.
long name and units are read from metadata
string fname$;//all the XF that deals with files default to fname$ string
findFiles path:=system.path.program$+"Samples\Batch Processing" ext:="*.csv" addpath:=1;//find all csv files under specified path and put found file names in fname$
impCSV //import all csv files
options.Mode:=1 //set Multi-file(except 1st) import mode as 1 so new csv files are put to new columns in same sheet
options.names.FNameToSht:=0 //sheet name will not be renamed
options.names.FNameToBk:=0 //bookname will not be renamed
options.names.FNameToBkComm:=0 //nook comments will not be renamed
options.names.FNameToColComm:=1 //put file name to column comments
options.names.FPathToComm:=0 //full path will not be included when renaming book/sheet/column with filename
options.HeaderLines.SubHeaderLines:=2 //set number of subheader as 2
options.HeaderLines.LongNames:=1 //put 1st line of subheader to column long name
options.HeaderLines.Units:=2 //put 2nd line of subheader to column units
options.partial.Partial:=2 //partial import from 2nd file on.
options.partial.FirstCol:=2; //partial import from 2nd column on