ni.com is currently experiencing slowness/issues due to ongoing maintenance.

Support teams are actively working on the soonest resolution.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A quite complicated string task

Solved!
Go to solution

Hello guys!

 

Today I got into a bit of mess when making a program for my company. I'm reading from a .csv file which is containing information regarding electric components. I have to read the cell into an array for further use. No problem at all.

Now the hard part:

Lets say a cell in the .csv file contained this: C1-C10

I put it into an array and still have: C1-C10

(C1-C10 means there are actually ten cmponents; C1, C2, C3...C10)

I now want to convert the array containing C1-C10 into an array looking like this:

 

C1

C2

C3

.

.

.

C10

 

(Se attachment LV2010)

 

I think a solution is to remove the C from the string and then look at the numbers and find out how many components there are. Then put it back with a C in front and create ten incrementing numbers like this:

C1-C10 => 1-10 = Ten elements => Create numbers: 1,2,3,4,5,6,7,8,9,10 => Add C in front of the numbers.

 

Anyways this algorithm has to be capable for any letters and numbers, i.e. R2-R5, K2-K7 etc...

Anyone which has done a similar thing and maybe can help me in the right direction on where to start?

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 1 of 11
(4,981 Views)
Solution
Accepted by topic author EvenDeejay

Here is my attempt.  I split the string at "-" with Match Pattern and then search each substring for leading letters.  Use the numeric parts to create an array of integers and convert back to strings.

 

Lynn

Message 2 of 11
(4,953 Views)

Please save your VI in 8.6 and post

 

Smiley Wink

-----

The best solution is the one you find it by yourself
0 Kudos
Message 3 of 11
(4,952 Views)

Here is my VI saved back to LV8.0.  The original VI just had the Array to Spreadsheet String part at the top.

 

Lynn

Message 4 of 11
(4,945 Views)

Maybe this is Rube Goldberg Code but, here is my version using regular expressions and so on... :

 

rube goldberg.png

exemple.PNG

 


File in LV 8.0.

 

Regards,

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
Message 5 of 11
(4,929 Views)

This version corrects a mistake concerning the regular expressions I used.

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
Message 6 of 11
(4,919 Views)

This Regular Expression uses a backreference and grouping to extract the letter and start/end numbers; the rest is easy.

 

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 7 of 11
(4,905 Views)

I explained the regular expression here.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 8 of 11
(4,876 Views)

 

I explained the regular expression here.

 

Jim, CLD

 


 

Hi Jim,

 

This is awesome !

 

Thanks ! I learned a lot today thanks to you and your example.

 

Regards,

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
0 Kudos
Message 9 of 11
(4,865 Views)

 


@helmut O'Brian wrote:

 

Thanks ! I learned a lot today thanks to you and your example.

 

Regards,


You're welcome.  I learned everything I know from the link in my signature and Darin.K.

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 10 of 11
(4,859 Views)