03-05-2015 01:26 PM - edited 03-05-2015 01:35 PM
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
03-05-2015 01:45 PM
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?
03-05-2015 01:47 PM
Look at your text files. Do they have an empty line at the end? That would cause it.
03-05-2015 01:52 PM
I dont think thats the problem because the array automatically starts with 0,0 when the text files start with a value
03-05-2015 02:14 PM
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
03-05-2015 03:06 PM
@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)
03-05-2015 03:12 PM - edited 03-05-2015 03:14 PM
@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
It is pointless to show an image. Attach the actual VI!
For example...