⎕VFI empty delimiter behaviour
2 posts
• Page 1 of 1
⎕VFI empty delimiter behaviour
⎕VFI handling of empty delimited text ...
⎕VFI flags valid numeric values with a '1' in the first returned vector and corresponding values in the second vector. Non-numeric values are marked with a '0' in both vectors. In edge cases, when a delimiter appears at the start, end or in succession within the string, the current behavior treats these delimiters as indicating empty values that default to a valid numeric '0', as illustrated below (brackets added for clarity):
'x'⎕VFI'xMyx2xxHatx3x'
Returns: (1 0 1 1 0 1 1) (0 0 2 0 0 3 0)
Similarly when the function encounters a blank string between delimiters; the blank is also treated as a valid numeric '0':
'x'⎕VFI'xMyx2x xHatx3x'
Currently returns: (1 0 1 1 0 1 1) (0 0 2 0 0 3 0)
The presumption that all empty spaces inferred by delimiters equate to a valid numeric 0, particularly in the case of explicit blanks, may not be universally applicable. I propose introducing a variant option, such as ⍠ n where n could be 0 or '', thus providing an explicit override for the default "empty" condition. Thus, for example:
'x'(⎕VFI ⍠'') 'xMyx2x xHatx3x'
Proposed return: (0 0 1 0 0 1 0) (0 0 2 0 0 3 0)
It's possible I've overlooked a caveat in the documentation, but based on my findings and proposed solution, I believe this change could enhance the function's flexibility and better handle edge cases.
⎕VFI flags valid numeric values with a '1' in the first returned vector and corresponding values in the second vector. Non-numeric values are marked with a '0' in both vectors. In edge cases, when a delimiter appears at the start, end or in succession within the string, the current behavior treats these delimiters as indicating empty values that default to a valid numeric '0', as illustrated below (brackets added for clarity):
'x'⎕VFI'xMyx2xxHatx3x'
Returns: (1 0 1 1 0 1 1) (0 0 2 0 0 3 0)
Similarly when the function encounters a blank string between delimiters; the blank is also treated as a valid numeric '0':
'x'⎕VFI'xMyx2x xHatx3x'
Currently returns: (1 0 1 1 0 1 1) (0 0 2 0 0 3 0)
The presumption that all empty spaces inferred by delimiters equate to a valid numeric 0, particularly in the case of explicit blanks, may not be universally applicable. I propose introducing a variant option, such as ⍠ n where n could be 0 or '', thus providing an explicit override for the default "empty" condition. Thus, for example:
'x'(⎕VFI ⍠'') 'xMyx2x xHatx3x'
Proposed return: (0 0 1 0 0 1 0) (0 0 2 0 0 3 0)
It's possible I've overlooked a caveat in the documentation, but based on my findings and proposed solution, I believe this change could enhance the function's flexibility and better handle edge cases.
- magnetron
- Posts: 2
- Joined: Tue Sep 06, 2016 9:29 am
- Location: New Zealand
Re: ⎕VFI empty delimiter behaviour
Funny I never noticed that behavior, it really seems it should not return a valid number.
For what it's worth, I have taken to using ⎕CSV rather than ⎕VFI for many use cases. It will handle conventional negative signs, thousands separators, and not turn blanks into valid zeros.
For what it's worth, I have taken to using ⎕CSV rather than ⎕VFI for many use cases. It will handle conventional negative signs, thousands separators, and not turn blanks into valid zeros.
- paulmansour
- Posts: 431
- Joined: Fri Oct 03, 2008 4:14 pm
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: Bing [Bot] and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group