Import ASCII file. This is an improvement(speed etc.) to ImportASCII.
int ImportASCIIFile( LPCSTR lpcszFilename, AsciiImportOptions & stAscImp, DataRange * pRange = NULL, DWORD dwCtrl = 0 )
0 on success, otherwise returns error codes
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); }
origin.h