LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remove tabs of zeros in array

Hi I have a VI that reads multiple text files and sends them into an array. However, when displayed on the array in between each seperate file is a row of zeros. Not really sure why, does anyone know how to get rid of it? Below is a picture of the block diagram i have now

 

Untitled.png

0 Kudos
Message 1 of 7
(4,165 Views)

First of all it seems you want a 2D array, so there are 2 separators (one for the rows and one for the columns). LabVIEW will automatically recognize any linefeed and carriage return as a row separator. But what is your column separator? By default it's a tab, but it seems you wired an empty string?

0 Kudos
Message 2 of 7
(4,146 Views)

Look at your text files.  Do they have an empty line at the end?  That would cause it.


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 3 of 7
(4,142 Views)

I dont think thats the problem because the array automatically starts with 0,0 when the text files start with a value

0 Kudos
Message 4 of 7
(4,133 Views)

I think the answer to your question is that the code is doing exactly what you told it to do.

 

I'm assuming that each file consists of a single line having a 1-D array of numeric data.  When you read the first file in, you build a 2-line string with the Concatenate function in the middle of your diagram, the first line having the single entry "0", the second the string you read.  You then give this to the "Spreadsheet to Array" function -- since Arrays have to have all rows the same length, the single 0 gets turned into a row of zeros.

 

Now you read the second file, concatenating its string on the end of the first string.  Could there be a blank line in there?  Don't know.  You again create an array (doing the first conversion over again), and so on.

 

Suggestion -- have one loop that just reads your files, bringing the content of each file to an array-indexed output tunnel (which will give you an array of strings representing 1-D arrays).  Before doing anything else, look at this array and see if it makes sense to you (has no blanks, zeros, etc.).  Now you have all of your string data, and need only to turn it into a 2-D array, which you can either do in a second loop or see if Spreadsheet to Array will do it for you (I've never used this function, so I'm uncertain of its function).

 

Bob Schor

0 Kudos
Message 5 of 7
(4,121 Views)

@Bob_Schor wrote:

I think the answer to your question is that the code is doing exactly what you told it to do.

 

I'm assuming that each file consists of a single line having a 1-D array of numeric data.  When you read the first file in, you build a 2-line string with the Concatenate function in the middle of your diagram, the first line having the single entry "0", the second the string you read.  You then give this to the "Spreadsheet to Array" function -- since Arrays have to have all rows the same length, the single 0 gets turned into a row of zeros.

 

Now you read the second file, concatenating its string on the end of the first string.  Could there be a blank line in there?  Don't know.  You again create an array (doing the first conversion over again), and so on.

 

Suggestion -- have one loop that just reads your files, bringing the content of each file to an array-indexed output tunnel (which will give you an array of strings representing 1-D arrays).  Before doing anything else, look at this array and see if it makes sense to you (has no blanks, zeros, etc.).  Now you have all of your string data, and need only to turn it into a 2-D array, which you can either do in a second loop or see if Spreadsheet to Array will do it for you (I've never used this function, so I'm uncertain of its function).

 

Bob Schor


Or use Join Strings from hidden Gems (vi.lib\Advance Strings\Join Strings vi)


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 7
(4,091 Views)

@libbyherself wrote:

Hi I have a VI that reads multiple text files and sends them into an array. However, when displayed on the array in between each seperate file is a row of zeros. Not really sure why, does anyone know how to get rid of it? Below is a picture of the block diagram i have now

 

Untitled.png


It is pointless to show an image. Attach the actual VI!

 

For example...

  • what is the display format for the various string diagram constants? What do they contain?
  • What's in the files you read? Can you attach a typical example of such a file?
  • Why is the shift register initialized with a string of the character zero?
  • Why the the array output not autoindexing? If you only want to parse the final string, "spreadsheet string to array" belongs after the FOR loop. (sunce you are concatenating all data in a shift register, the final iteration will contain the data from all files.
  • What's the purpose of the while loop? How often do you want to re-read the same files? Once is probably enough, right? (There even seems to be yet another while loop outside that one)
0 Kudos
Message 7 of 7
(4,088 Views)