From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing row not a column to txt File

Hello everyone, I am Facing a problem that i am writing 1D array data to txt file, The data are represented as a Column in the txt file.
When I need to Read the data from that txt file I use Read Spreadsheet block, but i get only the first element because the VI Indicate the First Row Only, I tried to find a way to transpose the 1D Array but i didn't find anyway to.
How can i solve this problem
Here's My Vi

0 Kudos
Message 1 of 3
(2,191 Views)

@El-Awny wrote:

Hello everyone, I am Facing a problem that i am writing 1D array data to txt file, The data are represented as a Column in the txt file.
When I need to Read the data from that txt file I use Read Spreadsheet block, but i get only the first element because the VI Indicate the First Row Only, I tried to find a way to transpose the 1D Array but i didn't find anyway to.
How can i solve this problem
Here's My Vi


Some comments:

  • You are using LabVIEW 2013, which used an older form of this function (I forget when it became Read/Write Delimited Spreadsheet -- the name changed, it gained the Error Line, but I think the rest of the functionality remained the same, though I can't check as I don't have 2013 installed).
  • You didn't attach either a sample Names.txt nor a sample <Patient>.txt file, so we can't easily "see" your data files and make direct suggestions "based on reality".
  • Assume that <Patient>.txt is (for some reason) a 1-column by 6-row file of strings without <tab> separators.  If you read it in as a 2D array, you can set the "Transpose" input to the Read Delimited Spreadsheet function to output a 2D array of 1 row, 6 columns.  If you now pass this through an Index Array (note that you don't need to wire the "index" input, as it is 0 by default), you'll get out the 1D array of 6 strings that I think you want.
  • Similarly, to get the six elements of this string, simply use Index Array, drag down the bottom edge 5 more times, wire none of the index inputs, and it will give you elements 0, 1, 2, 3, 4, 5 (and save you a lot of wiring and the possibility of making a mistake).

Bob Schor

0 Kudos
Message 2 of 3
(2,173 Views)

I'm confused about which file you are having issues with.  To go a little further, why do you even have multiple files?  Seems like you could just have 1 file that contains a row for each patient.  Read the entire file, Index out the first column (name), and use Search 1D Array to find your desired row.  If now, just use Index Array to get that row and parse out.  If not found, add to the end of the file.


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 3
(2,153 Views)