2.2.4.12.14 Datasheet::ImportASCIIFile

Description

Import ASCII file. This is an improvement(speed etc.) to ImportASCII.

Syntax

int ImportASCIIFile( LPCSTR lpcszFilename, AsciiImportOptions & stAscImp, DataRange * pRange = NULL, DWORD dwCtrl = 0 )

Parameters

lpcszFilename
[input] A full path ASCII file name
stAscImp
[input] An AsciiImportOptions struct that has been setup with import settings
pResult
[input] target DataRange. If NULL, it will import to current Datasheet.
dwCtrl
[input] additional options from the IMPASC_* enumeration.

Return

0 on success, otherwise returns error codes

Examples

EX1

void ImportASCIIFile_ex(string strFile)
{
	Worksheet wks = Project.ActiveLayer();
	DataRange dr;
	dr.Add(wks, 0, NULL, -1);
	
	AsciiImportOptions optASCII;
	init_ascii_import(optASCII.ascimp);
	init_CSV_import(optASCII, strFile);	
	
	DWORD dwCntrl = IMPASC_SKIP_QUOTED_EOL | AFCH_SET_NUMERIC_COL_BIG_ROWS;
	int nRet = wks.ImportASCIIFile(strFile, optASCII, &dr, dwCntrl);
	out_int("ret = ", nRet);
}

EX2

void ImportASCIIFile_Partial_ex(string strFile)
{
	Worksheet wks = Project.ActiveLayer();
	DataRange dr;
	dr.Add(wks, 0, NULL, -1);
	
	AsciiImportOptions optASCII;
	init_ascii_import(optASCII.ascimp);
	
	optASCII.header.MainHeaderLines = -1;//to indicate scanning for main header
	string strMainHeader;
	init_CSV_import(optASCII, strFile, &strMainHeader);
	
	optASCII.partial.Partial = 1;
	lstrcpy(optASCII.partial.ColRanges, "2:0");	//---skip 1st col, 2:0 means from 2nd to last
	lstrcpy(optASCII.partial.RowRanges, "10:20");
	
	DWORD dwCntrl = IMPASC_SKIP_QUOTED_EOL | AFCH_SET_NUMERIC_COL_BIG_ROWS;
	int nRet = wks.ImportASCIIFile(strFile, optASCII, &dr, dwCntrl);
	out_int("ret = ", nRet);
}

See Also

Datasheet::ImportASCII

Header to Include

origin.h