BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Simple task. Read a CSV file and get the two columns, dropping the header row (seen here)

 

altenbach_0-1617380547065.png

 

Apparently, we need to read the file twice with different delimiters and transpose setting to get a 2D array, one transposed and one not, one containing the first column and one containing both columns, delete the first row or column, transpose or not as needed, delete one column if there is more than one, then reshape to a 1D array to get each column. I am running out of breath!

 

Equivalent code:

 

altenbach_0-1617381166583.png

 

Message 2261 of 2,571
(9,575 Views)

@altenbach wrote:

Simple task. Read a CSV file and get the two columns, dropping the header row (seen here)

 

altenbach_0-1617380547065.png

 

Apparently, we need to read the file twice with different delimiters and transpose setting to get a 2D array, one transposed and one not, one containing the first column and one containing both columns, delete the first row or column, transpose or not as needed, delete one column if there is more than one, then reshape to a 1D array to get each column. I am running out of breath!

 

Equivalent code:

 

altenbach_0-1617381166583.png

 


Classic altenbach🙂

Message 2262 of 2,571
(9,471 Views)

Some simple array operations to create a table from a 1D array while skipping one element (seen here

 

 

 

altenbach_0-1618243818961.png

0 Kudos
Message 2263 of 2,571
(9,280 Views)

Seen here

 

Maybe not true Rube Goldberg Code, haven't examined it in detail, but the oval in the picture scares me. If that is their code, what does their container look like? 🙂

 

Snap99.png

 

mcduff

 

 

Message 2264 of 2,571
(9,252 Views)

@altenbach wrote:

I am scratching my head for an hour but I still have that nagging feeling that this code fragment could be simplified.

altenbach_0-1616806827461.png

 

(seen here)

 


Are you suggesting that any wire branch could rename wire y to wire x?  Seriously,  that is a simple RELABEL of the value.  A poor way to relabel the wires value but, other methods are not as demonstrative.

 

How else would YOU relabel a wire?

 

WHERE: y =x (as scope. ) LET....

 

I know , I think that you forgot that jarjon.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2265 of 2,571
(9,083 Views)

@JÞB wrote: How else would YOU relabel a wire? 

... you are actually requesting rube code?... Is this now a rube competition?

 

relabel wire rube?relabel wire rube?

 

Wasn't there a rube sub-category called "WEC" (Wire equivalent code).

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Message 2266 of 2,571
(9,081 Views)

Type cast

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2267 of 2,571
(9,035 Views)

Except that wire labels are something else. Even if you have a formula node output and name it "y", then create an indicator on it, the indicator will be named "output variable", not "y". And if you show the wire label of that wire, it is initially blank.

 

According to my casual testing, a formula node cannot be used to change the name of a wire.

0 Kudos
Message 2268 of 2,571
(9,024 Views)

@altenbach wrote:

Except that wire labels are something else. Even if you have a formula node output and name it "y", then create an indicator on it, the indicator will be named "output variable", not "y".


The output label of a type cast is "*(type *) &x" when I tried it.

 

But why would you need this?

 

If the output is an indicator output of a VI, simply label the indicator how you want it.

If you want to use a unnamed bundler, but you want your elements labeled, wire a cluster constant.

If you want to use variant magic, well, this might actually be a decent way. Unless you start with a variant input.

 

I don't recall ever needing this.

Message 2269 of 2,571
(8,915 Views)

wiebe@CARYA wrote:
I don't recall ever needing this.

Yes, that was my point. We can label a wire manually for clarity, but otherwise the name is irrelevant.

 

(As mentioned much earlier, if we need to ensure that a data copy is made to work around a compiler issue, we have the "always copy" function. Any other kludge clouds the intent of the programmer and might even get optimized out by the compiler.) 😄

Message 2270 of 2,571
(8,890 Views)