Skip to main content
Participating Frequently
Jan 31, 2020 9:54 PM UTC
Answered

tilde delimited sting into a list

Good afternoon. My apologies for the flurry of questions. This may seem like a rerun but I am working on a process that pulls in lines from a file one at a time. Each string is basically a list of tilde delimited values. Some of these values can vary in length or be NULL. I need to change the value of certain items in that list. I have tried using ListSetAt() to try to do this. I use the syntax below against the line below that. This should be changing the value of position 13 in that string, which is currently 48 to a value of 9. Rather, it is changing the value of what is now 0.3414 in position 16. It appears that it is still not recognizing those NULL values between tildes despite having that "YES" argument at the end. Again, any help would be appreciated.

 

         <cfset row = ListSetAt(row,14,9,"~","YES")>

 

MEPMD01~2POOP519~03092019113800PM~6480081580~~~1224714818389~OK~E~KWH~~000015~48~03092019124500AM~00~0.3414~00~0.3396~00~0.1182~00~0.0552~00~0.069~00~0.0642~~~~~~~~~00~0.0606~00~0.081

This topic is closed to new replies. Start a new post to keep the conversation going.
WolfShade
WolfShadeCorrect answer
Legend
Jan 31, 2020 10:11 PM UTC

Unless I'm missing something, the value of 48 is in the 13th position, not 14th, if I count correctly.

 

But aside from that, you'd probably have better luck by converting the list to an array (with including empty values) and changing the array by the index position, then convert back to a list.

 

HTH,

 

^ _ ^

6 replies

WolfShade
WolfShadeCorrect answer
Legend
Jan 31, 2020 10:11 PM UTC

Unless I'm missing something, the value of 48 is in the 13th position, not 14th, if I count correctly.

 

But aside from that, you'd probably have better luck by converting the list to an array (with including empty values) and changing the array by the index position, then convert back to a list.

 

HTH,

 

^ _ ^

Translate
PhamaldaAuthor
Participating Frequently
Jan 31, 2020 10:21 PM UTC

Oh yes sir. Sorry about that. I have made that change above. That should be position 13. 

Translate
BKBK
Community Expert
Community Expert
Feb 1, 2020 2:43 PM UTC

When I run the code 

 

<cfset row="MEPMD01~2POOP519~03092019113800PM~6480081580~~~1224714818389~OK~E~KWH~~000015~48~03092019124500AM~00~0.3414~00~0.3396~00~0.1182~00~0.0552~00~0.069~00~0.0642~~~~~~~~~00~0.0606~00~0.081">
<cfset row = listSetAt(row,13,9,"~","yes")>
<cfoutput>#row#</cfoutput>

 

I get the output: MEPMD01~2POOP519~03092019113800PM~6480081580~~~1224714818389~OK~E~KWH~~000015~9~03092019124500AM~00~0.3414~00~0.3396~00~0.1182~00~0.0552~00~0.069~00~0.0642~~~~~~~~~00~0.0606~00~0.081

So, please mark WolfShade's suggestion as the correct answer.

Translate