LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting specific text data and displaying it

Hi all,

 

First time posting here, so I will try to explain the problems I am running into. I am in the process of creating a basic database program. I will have various input fields that the user will enter, and when complete, those results will be written to a .txt file. Some of those input fields will be things like part number, location, date opened, and date completed. Now, I don't have any issues with this part of the coding, but I am running into trouble when it comes to reading and extracting specific data from that .txt file.

 

Example 1:  (Part Number, Location, Date Opened, Date Completed, assigned technician)

Inputs written: Part 1, Warehouse, 12/7/14, 12/9/14, John D.

Inputs written: Part 2, Repair, 12/6/14, 12/9/14, Jake C.

Inputs written: Part 3, Warehouse, 12/5/14, Not yet completed, John D.

and so on..

 

Now, the text file will continue to expand as users keep creating new records. Like I mentioned, I am running into problems when extracting specific dataa. For example, I want to extract some of this data from my text file.

 

1. Show only the data that does not currently have a completed date.

--> Indicator output should show one line from example above:

Part 3, Warehouse, 12/5/14, Not yet completed, John D.

2. Show only the data that has the assigned technician as John D.

--> Indicator output should show 2 lines from example above:

Part 1, Warehouse, 12/7/14, 12/9/14, John D.

Part 3, Warehouse, 12/5/14, Not yet completed, John D.

 

 

I hope this makes sense. Any help or guidance would be greatly appreciated.

 

Thanks!

0 Kudos
Message 1 of 5
(3,554 Views)

Creating and maintaining databases is its own specialized Computer Science topic!  There's lots of (complicated) thought that goes into their design and implementation.

 

Thus don't try to reinvent the wheel.  First question -- does something like a spreadsheet work for you?  Could you, in fact, keep your data in Excel?  LabVIEW has two ways of reading spreadsheet-like files -- there are VIs that read and write spreadsheets, and the Report Generation Toolkit can read and write Excel files.

 

One of the virtues of working with a defined file structure is that you don't have to worry (as much) about parsing your data, you can let LabVIEW handle that for you.

 

BS

0 Kudos
Message 2 of 5
(3,539 Views)

So, I should of mentioned other things I have tried so far. I didn't want my initial post to get too long though. Like I mentioned before, the writing part of this project works great. I write the input data to both an Excel spreadsheet (.xlsx), and a text file (.txt). No problems there. I worked for a few days trying to figure out how extract my data from the excel spreadsheet using  the report generation toolkit, and read from spreadsheet file vi's, but wasn't successful.

 

I can get it to display all my data to either a string indicator or an array, but that's just the start of things for me. I am wanting to extract specific rows and columns from my file, and display them to the end user. For example, say I have 100 entries in my spreadsheet file, and 50 of those entries do not have a completion date. How would I read from those 100 entries, and only show those 50 specific files that do not have the completion date? Those are the kinds of things I am trying to do. Hope this makes sense.

 

Thanks again for the help.

0 Kudos
Message 3 of 5
(3,530 Views)
Please don't describe a 'basic database program' as a text file. Use a real database and all of your problems would go away.
0 Kudos
Message 4 of 5
(3,519 Views)

I agree that a .txt file is not a database... There's is an add-in for data base operations in LabVIEW, called "Raima Database API for LabVIEW", and another one called "SQLite LabVIEW". You can buy it and install via the VI Package Manager.

 

If you decide to stick to text-based file, you should at the very least use .csv files, which eases the process of reading data in to an array somewhat. Aside from that, there's a "spreadsheet string to array" and an "array to spreadsheet string" function you could use. 

 

Strings can be parsed to extract useful information concerning time, and you can convert to timestamp if you wish.

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
0 Kudos
Message 5 of 5
(3,489 Views)