T O P I C R E V I E W |
bcorasol |
Posted - 07/21/2003 : 12:51:32 PM I just want to know what each parameter in ASCIMP structure means... The parameters are: int iDelimited; int iDelimiter; char cChar; char szFixedWidth[MAX_FIXED_COL_WIDTH]; int iHeaderLines; int iSubHeaderLines; int iAutoSubHeaderLines; int iAutoColTypes; int iTestLines; int iMode; int iNumcolumns; int iPartial; int iPartialC1; int iPartialC2; int iPartialR1; int iPartialR2; int iRenameWKS; int iApplyRange; int iRenameCols; int iLabels; int iMaxLabels; int iLeadingZeroes; int iNonnumeric; int iSkipRows;
I'll be very grateful for some informations. |
11 L A T E S T R E P L I E S (Newest First) |
londoncalling |
Posted - 05/16/2011 : 10:41:42 AM A well deserved thank you is in order here! Thanks very much you are a much better man than I am, this was driving me mad. |
williamguyer |
Posted - 05/12/2011 : 10:49:18 AM very good solution. i think this will do |
TreeNode |
Posted - 05/12/2011 : 10:30:37 AM My solution for now: I wrote a method which reads first part of my data file. It searches for '.' respectively ',' Depending on what decimal seperator is found, I set manually the property "nNumSep" of the ASCIMP struct to NF_IS_AMERICAN or NF_IS_EUROPEAN. Works fine.
Please check method AscImpReadFileStruct(), seems that it can not determine the appropriate number format in the case described above.
|-- TreeNode ...|-- a?? ...|-- ha!! |
billygiann |
Posted - 05/12/2011 : 03:15:05 AM this topic also helped me.it was really usefull.thanks |
ginastokes |
Posted - 05/10/2011 : 9:37:59 PM quote: Originally posted by cpyang
ASCIMP was not really intended to be used comppletely programmatically. We typically call AscImpReadFileStruct to initialize it, and make small modification, then call ImportASCII in the worksheet class. I put put in some quick comments below
int iDelimited; // 1 if delimited, 0 if Fixed format, szFixedWidth must be filled if iDelimited==0
int iDelimiter; // used only if iDelimited==1, one of the ASCIMP_DELIM_TAB, ASCIMP_DELIM_COMMA etc
char cChar; // used only if iDelimited==1 && iDelimiter==ASCIMP_DELIM_OTHER, char to be used as delimiter
char szFixedWidth[MAX_FIXED_COL_WIDTH];// for iDelimited==0, comma separated string for each col width
int iHeaderLines; //file header, before those header that can be used as column headings
int iSubHeaderLines;//subheader block, after iHeaderLines, the number of lines to be used in column labels and names
int iAutoSubHeaderLines; //=1 ignore iSubHeaderLines, auto determine, =0 to use iSubHeaderLines
int iAutoColTypes;//to change column type according to detection, 0=diable, 1=use detection, 2=detect but not to change if text column
int iTestLines; // Number of lines used for structure testing that must be consistent
int iMode;//ASCIMP_MODE_REPLACE_DATA, ASCIMP_MODE_APPEND_COLS etc
int iNumColumns;//num cols found from auto detection
int iPartial; // =1 to specify partial import, =0 if whole file imported, ignore iPartialC1, iPartialC2, iPartialR1, R2
int iPartialC1;
int iPartialC2;
int iPartialR1;
int iPartialR2;
int iRenameWks; //=1 to rename worksheet, =0 to keep current name
int iApplyRange;// not used anymore,
int iRenameCols;//=0 to keep column names, =1 to rename columns using 1st line above detected data, =2 use 2nd line etc
int iLabels;//=0 to keep current column labels, =1,2 etc as 1st, 2nd line from top of sub header block to rename labels
int iMaxLabels;//number of lines in subheader block to be used in column label rename
int iLeadingZeroes;//=1 to consider 0123 as numbers, =0 if 0123 is considered as text
int iNonnumeric; // this has to do with what to do when none-numeric is found in numeric column
int iSkipRows; //allow skip rows, =0 if no skipping of rows
Hope this helps, and please do not hesitate to ask more speicific questions on how to program ascii import in Origin C.
CP
this info is new to me. thanks. |
TreeNode |
Posted - 05/10/2011 : 11:40:16 AM What I try to do is to handle different number formats. Usually I am using american number format, where decimal places are seperated by a dot '.' But when someone changed settings on the computer or a special program by mistake, it could happen, that the numeric values in the file I want to import are stored in european number format, with a comma ',' used as seperator for decimal places.
Now I found out, that there is a member in the ASCIMP struct called "nNumSep". Possible values are:
NF_IS_ORIGIN = -1, // follow current Origin Tools:Options settings NF_IS_WINDOWS = 0, // follow Windows settings NF_IS_AMERICAN, // 100,123.45 NF_IS_EUROPEAN, //actually German, 100.123,45 NF_IS_FRENCH, NF_IS_SWISS, NF_IS_UNKNOWN,
(defined in header file: oc_const.h)
Unfortunately the Global Function: AscImpReadFileStruct() determines the property "nNumSep" to NF_IS_UNKNOWN when reading my file. The file looks like this, when ',' is used as decimal seperator
time A B C 12,3 3,43 5,39 8,11 13,5 3,55 5,24 8,16 14,7 3,23 5,72 8,23 15,9 3,44 5,68 7,89 17,1 3,43 5,45 7,93 ...
Why does method AscImpReadFileStruct() does not determine that the number format is european?
|-- TreeNode ...|-- a?? ...|-- ha!! |
douglasboyer |
Posted - 05/10/2011 : 10:13:46 AM i'm confused with what you're trying to imply |
TreeNode |
Posted - 05/10/2011 : 09:06:18 AM Origin 8 SR6 Win XP
Hi,
I want to abort importing, if non-numeric values are found in a column. Can the member iNonnumeric of the ASCIMP struct help me?
Unfortunately, there is no description what happens when iNonnumeric == 1,2, ...
The reason why I want to abort is, that when numeric values in the file to import are presented like: 124,392 with a ',' instead of 124.392 with a '.' I think Origin then treats these values as text, and following routines fail.
|-- TreeNode ...|-- a?? ...|-- ha!! |
bcorasol |
Posted - 07/22/2003 : 08:59:23 AM Very thank you. Your answer was just what I need.
Bruno |
cpyang |
Posted - 07/21/2003 : 6:01:59 PM I have put together an example for ascii import in Fixed format files. I will just import an Origin C header into a worksheet.
void ascimp_fixed_format() { string strFile = GetAppPath(false) + "originc\\system\\wksheet.h"; ASCIMP ascimp; AscImpReadFileStruct(strFile,&ascimp); out_int("Auto detect found number of Columns = ", ascimp.iNumColumns); // we will just go ahead to set things up ourself. ascimp.iHeaderLines = 0; ascimp.iSubHeaderLines =0 ; ascimp.iAutoSubHeaderLines=0; // import into 4 columns, just for fun, we can setup column width anyway we want ascimp.iDelimited = 0; strcpy(ascimp.szFixedWidth,"5,34,15,43"); ascimp.iRenameWks = 0; // create a new worksheet and import Worksheet wks; wks.Create(); wks.ImportASCII(strFile, ascimp); }
CP
|
cpyang |
Posted - 07/21/2003 : 5:53:19 PM ASCIMP was not really intended to be used comppletely programmatically. We typically call AscImpReadFileStruct to initialize it, and make small modification, then call ImportASCII in the worksheet class. I put put in some quick comments below int iDelimited; // 1 if delimited, 0 if Fixed format, szFixedWidth must be filled if iDelimited==0 int iDelimiter; // used only if iDelimited==1, one of the ASCIMP_DELIM_TAB, ASCIMP_DELIM_COMMA etc char cChar; // used only if iDelimited==1 && iDelimiter==ASCIMP_DELIM_OTHER, char to be used as delimiter char szFixedWidth[MAX_FIXED_COL_WIDTH];// for iDelimited==0, comma separated string for each col width int iHeaderLines; //file header, before those header that can be used as column headings int iSubHeaderLines;//subheader block, after iHeaderLines, the number of lines to be used in column labels and names int iAutoSubHeaderLines; //=1 ignore iSubHeaderLines, auto determine, =0 to use iSubHeaderLines int iAutoColTypes;//to change column type according to detection, 0=diable, 1=use detection, 2=detect but not to change if text column int iTestLines; // Number of lines used for structure testing that must be consistent int iMode;//ASCIMP_MODE_REPLACE_DATA, ASCIMP_MODE_APPEND_COLS etc int iNumColumns;//num cols found from auto detection int iPartial; // =1 to specify partial import, =0 if whole file imported, ignore iPartialC1, iPartialC2, iPartialR1, R2 int iPartialC1; int iPartialC2; int iPartialR1; int iPartialR2; int iRenameWks; //=1 to rename worksheet, =0 to keep current name int iApplyRange;// not used anymore, int iRenameCols;//=0 to keep column names, =1 to rename columns using 1st line above detected data, =2 use 2nd line etc int iLabels;//=0 to keep current column labels, =1,2 etc as 1st, 2nd line from top of sub header block to rename labels int iMaxLabels;//number of lines in subheader block to be used in column label rename int iLeadingZeroes;//=1 to consider 0123 as numbers, =0 if 0123 is considered as text int iNonnumeric; // this has to do with what to do when none-numeric is found in numeric column int iSkipRows; //allow skip rows, =0 if no skipping of rows
Hope this helps, and please do not hesitate to ask more speicific questions on how to program ascii import in Origin C.
CP
|
|
|