LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing Multiple .txt files with delimiter

I need help parsing multiple .txt files from a local folder. Long story short, the .txt files I need are designated by a serial number that is fed into the main VI.

 

All the .txt files in this directory are opened and stored in a FGV sub VI. From here, another sub VI is supposed to parse out the .txt files' content for the given serial number. What ends up happening, is that the contents of the given serial number's .txt file gets appended to the top of the "parsed array" of all the .txt files while all the .txt files for other serial numbers just gets shuffled below the serial number's contents. How do I use delimiters to separate the individual .txt files that get pulled into memory? Main VI is attached.

0 Kudos
Message 1 of 10
(3,323 Views)

The VI you posted doesn't appear to have any relation to the questions you are asking. You simply posted a Vi that reads an INI file.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 10
(3,314 Views)

The .txt file parsing happens down the line in that VI. Its everything to the right of the FGV_Logs.vi . The .ini file simply tells the TF_Get_master_log_string.vi what folder path to find the .txt files and what the pattern of the .txt files' filename to be read into memory looks like. All that is fed into the FGV_Logs.vi where all the .txt files are stored in memory.

0 Kudos
Message 3 of 10
(3,304 Views)

Hi JD22,

The VI that you posted does not contain an FGV_Logs.vi sub-VI. The only sub-VIs in this VI is an open config data, three read key (variant) VIs, and then a close config data.

Regards,
0 Kudos
Message 4 of 10
(3,297 Views)

You apparently attached the wrong file. There is no FGV_Logs.vi call in the attached file.

0 Kudos
Message 5 of 10
(3,289 Views)

Attached is the FGV_Logs.vi. I can post all the VI's that are related to this main VI but am limited to 10 attachments per post.

0 Kudos
Message 6 of 10
(3,285 Views)

Don't ever attach more than 2 to a post.  When you need to attach more, Zip them up and attach that.  (And please use the .zip format, and not one of the other proprietary ones.)

 

I think you will need to attach more files.  This latest one doesn't seem to do much.  And neither one seems to have any arrays in them about the "parsed array" you are referring to.

0 Kudos
Message 7 of 10
(3,278 Views)

Thanks for that clarification on how to post multiple files. Zipped up the folder that has all the dependent sub-VI's for this main VI.

0 Kudos
Message 8 of 10
(3,268 Views)

First, you could use some cleanup of your code. Wires are flying everywhere. More importantly, if you are working with multiple logs, why are you storing them all in a single string? Why not store them as an array, with each log an array element. In addition, I would parse the actual log file and use a cluster to store the log data. It will make you code much easier to work with and maintain. You will avoid all of the string manipulation you are doing through your code.

 

Read your log file.

Parse that data into a meaningful cluster.

Store each cluster into an array of your log entries. Given you are working with serial numbers, you could also use a variable attribute list (or a map if you are using LV 2019) to store the entries. This makes the lookup very easy. but an array will work as well. Ultimately this should be determined by how many logs you would be reading in at one time. If the number is large, over 1000, the variant attribute list or map will provide better performance.

 

All of your downstream code will operate on the clusters, rather than worrying about the string manipulations to process the data. This has the added benefit that you can change you log file format and not have to change all of your code. You would only need to modify the parser.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 9 of 10
(3,256 Views)

Hi Mark_Yedinak,

 

I will definitely take your advice. I will change how the program is structured and use arrays to separate each of my logs. Thanks for the guidance. I'll let you know how this turns out once I get a working version of the new program working.

0 Kudos
Message 10 of 10
(3,227 Views)