LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

can more than one delimiter be use at the same time for spreadsheet string to array

I have a text header in my data file that is space delimited and the data in the file is tab delimited? Any suggestion?
0 Kudos
Message 1 of 6
(3,295 Views)
Either write the file in two pieces, the header first then append the rest of the data. Or if the entire thing is small enough, format the header and data in two pieces, concatenate the strings and then write to the file.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 6
(3,295 Views)
Mike the files have already been written by other persons. I'm tasked with reading them. Most of the time the header and data is written using the same delimiter. Recently I have found a few cases where one delimiter is used in the header and another in the data. There in, is my problem.
0 Kudos
Message 3 of 6
(3,295 Views)
Sorry, I misread your problem...

Is the header always of a fixed length in terms of the number of lines? Or can you easily find out from the file how long the header is? If so, you could first read just the header and, instead of using spreadsheet to array function, you could parse the header yourself by using the match string function in a While loop with the search value:

[\s\t]+

Assuming slash codes are enabled, this string will match any string of one or more spaces or tabs.

You could then read the rest of the file and format it using spreadsheet to array with the tab delimiter (that is constant, correct?).

If you need help with that parsing loop let me know and I'll write one for you...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 6
(3,295 Views)
Sure. If you know you have a header, read in the file one line at a time. Search the line for a tab; if the line has a tab, you're finished with the header. Using shift registers, save the position in the file; you can recall where you were on the last line of the header where there was no tab. This will be the starting point of your tab-delimited data.

Mark
0 Kudos
Message 4 of 6
(3,295 Views)
Hi,
I've made the example which parses the spreadsheet string with two delimeters in any order.
First you have to use the "Spreadsheet string to array" function with one of this delimeters which converts your data to array of STRINGS. In this case each string in array represents some data or the spreadsheet string with other delimeter. So now you just have to use "Spreadsheet string to array" once again for every other string in this array with the second delimiter. It will convert your data to the proper format.

The example is attached.

Oleg Chutko.
0 Kudos
Message 6 of 6
(3,295 Views)