Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

tilde delimited sting into a list

New Here ,
Jan 31, 2020 Jan 31, 2020

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

TOPICS
Advanced techniques
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 31, 2020 Jan 31, 2020

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
LEGEND ,
Jan 31, 2020 Jan 31, 2020

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 31, 2020 Jan 31, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2020 Feb 01, 2020

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 06, 2020 Feb 06, 2020

My apologies for the delayed response sir. That is so weird. I swear that wasn't working last week. I am still working with the option of converting that string to an array and then back. I do think that will be the best option. I'll keep you posted on that and mark that as answered as soon as I have that worked out. Thank you again for your time and effort. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2020 Feb 06, 2020

Converting to array and then back again is inefficient. If you're getting the wrong result, then some other factor might be at play. 

Just copy-paste the code above.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 19, 2020 Feb 19, 2020
LATEST

Once again, my apologies for the delay in getting back. This was exactly what I needed. Thanks once again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources