cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Concat string

JW_9781974
7-Bedrock

Concat string

How to take out some part of the number defined through evaluation definition and use it further for calculation.

For e.g. I have set of 3 number clubbed and 24 such sets separated by comma and space and would like to use 7 set for calculation purpose later in worksheet. Is there any possible solution for this 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:JW_9781974)

The data in your sheets seems to be copied text (!) from a word document.

What is the original format the data is actually provided in? I guess it can't be a text document but rather something like a csv file or the like.

 

Here is a stupid and dull way to handle the data as its provided in your example sheet:

1) Double click the region with the data

2) Word should open; select the data row and copy it using Ctrl-C

3) Switch back to Prime and type "data:=" (without the quotes) and then press Ctr-V to insert the data. The result should be that you created a string variable containing the data values separated by commas.

4) Now you can write a simple parser to separate the values in the created string, convert them to numbers and store the results in a vector

5) Now you can access individual vector values using the normal ways to deal with vectors.

 

Werner_E_0-1645141138154.png

 

But I am pretty sure that there will be much better ways to go once you reveal what format the actual data is provided in.

 

Prime 6 worksheet attached

 

View solution in original post

7 REPLIES 7

Please, upload the documents you're working with so I can understand.

Werner_E
25-Diamond I
(To:JW_9781974)

There sure may be solutions for your problem but I guess you will have to go into more detail describing what exactly you are looking for, give some concrete examples (stating the input and also the output you expect) and attach your sample worksheet.

I am adding the sample worksheet with same agenda 

Copy-paste the text into Excel. If it all ends up on one cell, use "Text to Columns" in the Sort & Filter pane of the Data tab, choosing comma as your delimiter. You'll have to copy the row and paste it transposed into column A to get it into the format you want. Save it as a .CSV

 

Use READEXCEL to upload the data into your mathcad sheet, or use an Excel component. (Your choice, based on what you're most comfortable with). Once you have an array loaded up with your excel data, you can play with it in MathCAD however you wish. 

 

Does this help?

Werner_E
25-Diamond I
(To:JW_9781974)

The data in your sheets seems to be copied text (!) from a word document.

What is the original format the data is actually provided in? I guess it can't be a text document but rather something like a csv file or the like.

 

Here is a stupid and dull way to handle the data as its provided in your example sheet:

1) Double click the region with the data

2) Word should open; select the data row and copy it using Ctrl-C

3) Switch back to Prime and type "data:=" (without the quotes) and then press Ctr-V to insert the data. The result should be that you created a string variable containing the data values separated by commas.

4) Now you can write a simple parser to separate the values in the created string, convert them to numbers and store the results in a vector

5) Now you can access individual vector values using the normal ways to deal with vectors.

 

Werner_E_0-1645141138154.png

 

But I am pretty sure that there will be much better ways to go once you reveal what format the actual data is provided in.

 

Prime 6 worksheet attached

 

StuartBruff
23-Emerald III
(To:Werner_E)

For those of you watching in Prime Express 7, here's one way of converting a separated string of numbers to a vector of numbers:

 

2022 02 18 a.png

 

Stuart

 

(sfind isn't really necessary; it's only there to shorten the first line of strsplit)

StuartBruff
23-Emerald III
(To:StuartBruff)

For those of you who noticed strsplit's reaction to an empty string for the separator string T, I'm afraid you'll need to either vectorize char(S) or use the more complicated version of char.

 

2022 02 18 b.png

 

I've added strjoin (and a few supporting functions, including a replacement for Prime's faulty search) to the attached worksheet - they're in the collapsed Area.

 

Stuart

Announcements

Top Tags