Appending new value in the CSV file

Ask general questions here.
deatchlock
Posts: 27
Joined: Mon Mar 19, 2018 10:02 am

Appending new value in the CSV file

Post by deatchlock » Tue Apr 03, 2018 9:55 am

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,

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Appending new value in the CSV file

Post by odklizec » Tue Apr 03, 2018 11:19 am

Hi,

Try to use "Add" method, as shown here:
https://www.ranorex.com/forum/writing-i ... tml#p34657
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

deatchlock
Posts: 27
Joined: Mon Mar 19, 2018 10:02 am

Re: Appending new value in the CSV file

Post by deatchlock » Tue Apr 03, 2018 12:16 pm

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?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Appending new value in the CSV file

Post by odklizec » Tue Apr 03, 2018 12:30 pm

How many columns are in your csv file? Could you please share a sample csv?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

deatchlock
Posts: 27
Joined: Mon Mar 19, 2018 10:02 am

Re: Appending new value in the CSV file

Post by deatchlock » Tue Apr 03, 2018 12:42 pm

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.
Attachments
TestScreen.csv
(155 Bytes) Downloaded 8 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Appending new value in the CSV file

Post by odklizec » Tue Apr 03, 2018 1:01 pm

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");
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

deatchlock
Posts: 27
Joined: Mon Mar 19, 2018 10:02 am

Re: Appending new value in the CSV file

Post by deatchlock » Tue Apr 03, 2018 1:14 pm

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: