LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert a single element in a 2D array ?

Solved!
Go to solution

I am trying to insert a single element into a 2D array but nothing seems to happen. What i am trying is to first index the required row of the 2D array and then write the new element to the end of that row. Then insert that modified array into the original 2D array ... so whats wrong and how to go about this ?

 

Insert Single ELement in 2D Array.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 11
(5,598 Views)

You can't replace a value that is not in the original array.  You have to use Build Array or Insert Into Array to add an entire column all at once.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 11
(5,574 Views)

Use this.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 11
(5,539 Views)

@paul_cardinale wrote:

Use this.


What is a VIM file ? Can you send a VI snippet ? Thanks

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 11
(5,518 Views)

@MogaRaghu wrote:

What is a VIM file ? Can you send a VI snippet ? Thanks


It is a Malleable VI, but that is new to LabVIEW 2017.  The VIM will autoadapt the inputs to whatever you wire up to them.  A very powerful tool.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 11
(5,510 Views)

Yeah i read about it after i saw the post...

 

Anyway i have LV15 only and as such can do nothing with it unless it is saved as a snippet for LV15.

 

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 6 of 11
(5,507 Views)

Here's a non-maleable (string only) version in LV 2015

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 11
(5,501 Views)

@paul_cardinale wrote:

Here's a non-maleable (string only) version in LV 2015


Thanks . This is good for a single dimension array. 

But i need to be able to manipulate a 2-D array. Let me explain :

1. User creates in Excel a CSV file that has 6 columns and N rows. ( The rows will depend on the specific plan data ). We will call this PLAN.CSV

2. I read this PLAN.CSV and take up each row and do something with that data. After the job is complete i need to be able to append three additional columns to that Row with Date / Time / Status string. This needs to be done for all the rows and once complete its called ACTUAL.CSV

3. To be able to do the above, i should initially take the PLAN.CSV and create three additional empty columns and call that file ACTUAL.CSV. As and when data becomes available i can then fill in element by element into the empty columns.

 

How to programmatically do the above ? . 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 8 of 11
(5,434 Views)
Solution
Accepted by topic author MogaRaghu

Hi Moga,

 

3. To be able to do the above, i should initially take the PLAN.CSV and create three additional empty columns and call that file ACTUAL.CSV. As and when data becomes available i can then fill in element by element into the empty columns.

How to programmatically do the above ? . 

1. You get a 2D array from your CSV file. Determine the column length ("how many rows has this array?")

2. init a "3 columns × rowsize" 2D array of empty strings (InitArray) and append it to your initial CSV array.

Finished:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 11
(5,432 Views)

Thanks GerdW.  This works :

 

InsertColumsInto2DArray.png

@GerdW

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 10 of 11
(5,414 Views)