Page 1 of 1

Appending new value in the CSV file

Posted: Tue Apr 03, 2018 9:55 am
by deatchlock
Hi,

I am trying to append the new values in to the existing CSV file without creating the new one. I have tried to do this : propTableRowsCSV.Append(new string[]{captionString}); but I always get an error message even when trying to call Append without any parameters. Does anyone have experience with this?

Thanks,

Re: Appending new value in the CSV file

Posted: Tue Apr 03, 2018 11:19 am
by odklizec
Hi,

Try to use "Add" method, as shown here:
https://www.ranorex.com/forum/writing-i ... tml#p34657

Re: Appending new value in the CSV file

Posted: Tue Apr 03, 2018 12:16 pm
by deatchlock
Hi odklizec,

I did try that but it overwrites the existing values with the new one therefore I have tried to use Append which is not working as expected to be more precise I donĀ“t know how to use it to append new values. Maybe there are some work arounds?

Re: Appending new value in the CSV file

Posted: Tue Apr 03, 2018 12:30 pm
by odklizec
How many columns are in your csv file? Could you please share a sample csv?

Re: Appending new value in the CSV file

Posted: Tue Apr 03, 2018 12:42 pm
by deatchlock
HI,

it depends from how many Text values are taken from the GUI since it populates the csv file during the runtime. At the moment I have made for each test case seperate csv file but in some situations I would need to have one csv for more test cases. Example in the attachment.

Re: Appending new value in the CSV file

Posted: Tue Apr 03, 2018 1:01 pm
by odklizec
I joust found that the Append method you are trying to use is from Linq. I'm not so skilled with Linq, so maybe someone else could help here? Anyway, in case of simple file like yours, I would use for example AppendAllText IO method...

Code: Select all

using System.IO;
...
File.AppendAllText(csvOutputPath,"123456789\n");

Re: Appending new value in the CSV file

Posted: Tue Apr 03, 2018 1:14 pm
by deatchlock
Hi,

thank you for the help. I am not skilled either but I will take a look in to it. I am not sure if a FileStream could be used in this case or will it be compatible with rest of the code? Anyway thank you :wink: