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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

6-Contributor

## 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

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(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.

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

7 REPLIES 7
8-Gravel
(To:JW_9781974)

24-Ruby V
(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.

6-Contributor
(To:Werner_E)

I am adding the sample worksheet with same agenda

8-Gravel
(To:JW_9781974)

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?

24-Ruby V
(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.

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

23-Emerald II
(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:

Stuart

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

23-Emerald II
(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.

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