LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save in a csv file only the passenger IDs different from 0 or empty and in order

Solved!
Go to solution

Hello everyone,
I need to save in a csv file only the passenger IDs different from 0 or empty and in order.
I only entered the IDs of passengers 1, 2 and 4.
The images below show what I have and what I want.
How do I do it please?
Thanks in advance

0 Kudos
Message 1 of 4
(771 Views)
Solution
Accepted by topic author Ngouda

You just need to rewire the code like bellow. 

The way you wired the code, you are concatenating the ID Passenger1: with the entered number. 

To get what you want, you just need to get the string control value, then Outside the loop you add the line with the labels ID passenger...

 

 

LVNinja_0-1687437096772.png

 

Message 2 of 4
(767 Views)
Solution
Accepted by topic author Ngouda

Hello, Ngouda.

 

     Is it your goal to take a single line (possibly from a one-line csv file?) and create a 2-line csv file consisting only of the entries that have a valid Passenger ID?

 

     If that is the case, it seems to me the following algorithm will work:

  1. Read a 1-line CSV file consisting of "ID PassengerN: TicketNumber" strings.  This gives you an Array of Strings having the form <ID PassengerN:><space><TicketNumber>.
  2. With a For Loop, use Scan From String to split the string into what I'll call a Header (for example, "ID Passenger1") and the Ticket Number (which could be characters or a blank).
  3. You ideally want to build two arrays, one of Headers and one of (valid) Ticket Numbers.  Do you know about Conditional Indexing Tunnels, which lets you only "pass out" into the output Array those values that you want, which in your case, are those where the Ticket Number is not an empty string?  Use this to bring out the array of (valid) [ID Passengers] and (valid) [Ticket Numbers]
  4. You now have two valid 1D arrays you can use to Write Delimited Spreadsheet (obviously, you write the ID Passenger array first, then the Ticket Numbers).

Bob Schor

 

P.S. -- I am using LabVIEW 2019 and 2021, so I couldn't open your attached VI.  Use "Save for Previous Version" to reach long-time LabVIEW Users (such as I) who might not update every year.

Message 3 of 4
(758 Views)

Hi @LVNinja, @Bob_Schor,

Thanks very much for your reply.
Thats work now what I want.
Have a good day 🙂

Message 4 of 4
(741 Views)