01-31-2019 07:06 AM
Hi all,
I want to read out letters and numbers from a textfile and store them in seperate arrays. My file looks like this: -23,-33,""-15,-19"N", (and so on, so it's always two numbers and one referencecomment, which I want to have in the same row of the arrays) . So I've tried it with the Spreadsheet String To Array Funtion, but with this I'm only getting the numbers (because they are seperated with , ) I would like to have the two numbers in a 2D array and the referencecomment in a 1D array.
My idea is now to search the string for " and save the next item in an array, but there's than the problem, that I also need the empty spaces ("") in the array. Now I am quite uninspired and hope you can help me.
Thanks
01-31-2019 07:29 AM - edited 01-31-2019 07:34 AM
Hi Bianca,
My file looks like this: -23,-33,""-15,-19"N", (and so on,
So there is:
- sometimes a comma before the quotation marks - and sometimes not (?)
- sometimes a comma after the quotation mark and the next number - and sometimes not (?)
Can you provide a VI (LV2017 preferred) with some example text in a string constant to clarify your requirements?
Having a comma as delimiter char used in general would make it quite easy:
(Just to give an idea. Apply conversion from string to numbers, transposing the numeric array, and stripping of the quotation marks on your own.)
02-04-2019 04:45 AM
Hi Gerd,
thank you for your reply. My problem is, that I am not allowed to manipulate my file. So, as you already said, there is sometimes a positive and sometimes a negative number after the quotation mark, but there is never a comma.
My idea is to search the string for the quotation mark and then save the element after it (so index +1) into an array or something like this. I will try this.
Of course I would prefer an easier and nicer way to do this but I think it will not work with the Spreadsheet String To Array function, because I would only need the field between "" and that is not working. (I just used 2 Spreadsheet String To Array functions, so one for the numbers and the other one for my letters, but it's also not working). I added a part of my LabVIEW program so I hope it's a little bit easier to understand what I mean. I hope you can help me.
Thanks.
Best regard,
Bianca
02-04-2019 04:50 AM
Hi Bianca,
you still don't provide an example of your textfile in an attachment.
So, as you already said, there is sometimes a positive and sometimes a negative number after the quotation mark, but there is never a comma.
In your first message there's a comma after the quotation, so please provide an example we can work with!
Suggestion:
Separate the strings by the comma delimiters.
Then check each string for quotation marks to separate number and comment…
02-04-2019 04:54 AM
Hi,
I'm sorry, I forgot. I added an example. I hope it worked.
Br,
Bianca
02-04-2019 05:20 AM
Salut,
ai incercat cu functia Match Pattern?
02-04-2019 05:36 AM - edited 02-04-2019 05:39 AM
Hi Bianca,
your problem is so easy to solve because there are Linebreaks in the text! You should have posted that example much earlier - and you should have used a real text editor like Notepad++:
Suggestion:
- Read the text as spreadsheet with a comma delimiter
- convert the first two columns to numbers
- strip the quotation marks from third column items (you may use any RegEx/MatchPattern you like instead of my approach)
- build an array of cluster with all the information…
02-04-2019 07:04 AM
Thanks, that helped me a lot. 🙂