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
 Splitting vector rowwise
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 12/07/2021 :  11:04:42 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2022
Operating System: win10

I have a xml file in which I read a string value that actually represents many vectors
string looks like this:
"0,19,126,163,29,0,0,0,0,0,
0,0,0,209,0,0,35,148,159,264,
468,66,421,706,639,506,399,716,604,382,
535,414,304,563,493,223,250,6,53,0,
0,0,81,0,0,0,0,0,0,0,
....
and so on"

I can put it into a vector<string> with GetTokens(), but then I need to further extract each element into separate vectors.
This is doable with a loop but this is way too slow (I have more than 20000 lines)

Is there any method that could speed things up ?
This string has the same structure than an ascii file, would it be possible to use ImportASCIIFile(), with a string instead of a file ?

Thanks

cpyang

USA
1406 Posts

Posted - 12/07/2021 :  2:14:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
We can easily add this to matrixbase, I added

https://originlab.jira.com/browse/ORG-24624

CP
Go to Top of Page

couturier

France
291 Posts

Posted - 12/08/2021 :  02:38:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks a lot
Go to Top of Page

minimax

351 Posts

Posted - 01/19/2022 :  01:36:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

In 2022b Beta version, we added a function SetByText() for matrixbase.

void st(string str="1,2,3\r\n2,3,4\r\n7,8,9\r\n")
	{
		matrix<int> mm;
		mm.SetByText(str);
		Worksheet wks = Project.ActiveLayer();
		mm.CopyTo(wks);//default will transpose
	}


People who is interested may try.
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