How to delete comma(,) to the last row in C#

Here is my filterdata output
‘41a7637f-bf62-4a82-9299’,
'f00463ea-af88-41b4-9d36,

I need to remove comma(,) of the last line in text box
Used TrimeEnd(“,”) but it remove all comma’s
USed Trim also
used (str).Remove(str.Length-1)

hey,
you can use
TEXT.trimEnd(","c)
where TEXT is string Variable
Thanks,
Rounak

image
with that expression facing the syntax error and my process is in C#

Hey,
In C#
you can write
TEXT.TrimEnd(‘,’)

Thanks

Hi,

Can you try the syntax in below,

strinput.Remove(strinput.Length-1,1)

Capture

Hey!

Can we try this:

StringVariable.Substring(0,StringVariable.Length-1);

Regards,
NaNi

with these expression the bot removes all comma(,) for all rows

with these expression the bot removes all comma(,) for all rows

I have rows in the input and i need to remove the comma(,) to last row

so the input is in excel and you need to remove for the lastrow in excel file or while writing to excel?

My input is in rows and i need to remove Comma for the last row only

Could please share the screenshot image of output like, how output looks like

These is my input
‘41a7637f-bf62-4a82-9299-be1e392483a2’,
‘f00463ea-af88-41b4-9d36-5ec3dc0b14df’,
‘c511c7a7-f756-44c5-943c-2e8df7355b95’,
‘d8fa4837-098c-4bff-9ba3-d37bfff1d12e’,
‘e3baa1a8-14a2-4b56-9a86-df1fa27832bb’,
So the output sholud be in
‘41a7637f-bf62-4a82-9299-be1e392483a2’,
‘f00463ea-af88-41b4-9d36-5ec3dc0b14df’,
‘c511c7a7-f756-44c5-943c-2e8df7355b95’,
‘d8fa4837-098c-4bff-9ba3-d37bfff1d12e’,
‘e3baa1a8-14a2-4b56-9a86-df1fa27832bb’

Hey!

Could you please provide some more details…

What we actually trying to do here?

From where we’re getting this data?

I mean is this a text file or CSV or Excel file?

Regards,
NaNi

Try this:

StringVariable.remove(StringVariable.LastIndexOf(","))

Reference:

Regards,
NaNi

I am getting the data from FilterDataTable and i am trying to append into text file and then tying to remove the comma for the last row in that text file…

1 Like

Try this and let me know…

This will remove the last comma which is present in the text…

Regards,
NaNi

thanks for your response bro

1 Like

Are you getting this because you’re concatenating multiple values and adding “,” at the end each time? Like…

For Each

  • myVar = myVar + someString + “,”
    End For Each

If so, do it the other way around. Use an If to see if it’s the first value. If it is not the first value, add a comma:

For Each

  • If someString.IsNullOrEmpty
    – Then myVar = someString
    – Else myVar = myVar + “,” + someString
    End For Each

Then when it’s done you won’t have the , at the end.

Hey!

Mark the appropriate post as solution and close the thread

Regards,
NaNi

1 Like

No, the case is different…

Regards,
NaNi