The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 ASCII Import - semicolon as delimiter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

flexmann

Denmark
1 Posts

Posted - 07/15/2011 :  09:52:39 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: Origin Pro 8.0.63.988 SR6
Operating System: Windows XP Professionell 2002/ Windows 7 Enterprise

Hi.

I would like to write a C file to import a data file to do some further operations automatically.
For a data file with tabs as a delimiter, the following code works fine, but unfortunately, the relevant files have semicolons as delimiters. Therefore, the program doesn't import the data file.

What can I do make the program recognizing the semicolon as the delimiter?

By using the import wizard, I have already saved a filter, that can import the data file. Is it also possible, to implement this filter in the ASCII import in the code?


#include <stdio.h> 
#include <Origin.h>
#include <wksheet.h>
#include <Array.h>

int TPD()
{
	string file1 = GetOpenBox("*.csv");
	
	Worksheet wks1;
	wks1.Create();
	wks1.GetPage().Rename("H2O_date",FALSE,TRUE);
	
	
	ASCIMP	ai;
		if(AscImpReadFileStruct(file1, &ai)==0)
		{	ai.iAutoSubHeaderLines = 0;
			ai.iMode = ASCIMP_MODE_APPEND_COLS; 
			ai.iRenameCols = 0; column name
			ai.iPartial = 1; import 
			ai.iPartialC1 = 0; 
			ai.iPartialC2 = 5; 
			ai.iPartialR1 =40; 
			ai.iPartialR2 = 50; 
			int nRet =  wks1.ImportASCII(file1, ai);
			out_int("nRet = ", nRet);
		}
		return 0;
		
}


I hope you can help me.
Cheers, Felix

TreeNode

64 Posts

Posted - 07/15/2011 :  11:25:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi flexmann,

I think setting the property like this:
ai.iDelimiter = ASCIMP_DELIM_SEMICOLON;

should work for you.
Sadly I didnt not find the whole list of defined delimiters.
In helpfiles only the values ASCIMP_DELIM_TAB, ASCIMP_DELIM_COMMA and ASCIMP_DELIM_OTHER are listed.
I am using the value ASCIMP_DELIM_SPACE for this property, to import my files.

http://ocwiki.originlab.com/index.php?title=OriginC:ASCIMP

hope this helps.



|-- TreeNode
...|-- a??
...|-- ha!!
Go to Top of Page

Penn

China
644 Posts

Posted - 07/18/2011 :  06:13:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

This example will show you how to import a data file with semicolon as delimiter.

You can also import the data file by using a saved filter. See this page.

Penn
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000