Page 1 of 1

Adding/Appending new rows an existing csv file

Posted: Fri Jun 22, 2012 11:30 am
by nandeesh
Hi,

how to add new rows to a csv file using C# code. I have csv file with two column: Headers "ID" and
"Name". I referenced the code in ur blog to read the data from csv file using LoadData Method.
Pls tell me how to add using Storedata method.

Later i want bind these two columns to two global variables named ID and Name which are defined in
Repository. I am not using Recording Approach.

Thanks.

Re: Adding/Appending new rows an existing csv file

Posted: Mon Jun 25, 2012 2:09 pm
by Support Team
Hi,

I have attached a sample project for you. The sample shows how to add customized data to a data source.
I would suggest trying it this way.

I have pretty much 2 Test Cases. The first includes the code module where you can add your data to the data source you created through the Test Suite GUI. So, all your captured data from your GUI elements can be added to the data source table as shown in the code module.

The second Test Case provides the data source “myConnector” which is a simple data table you need to create initially, it could also be a csv connector. I added to columns and bound 2 variables from a recorder. I just write the values into the reporting file (just to demo it). In the code module I add a row with 2 values.

So, what you can do is the following: just create a simple data source table as shown above. Then use a code module to dynamically add the captured data to the data source. Each recording/usercodefile which uses the data source will now iterate through all the rows you added, using the data you captured from your GUI elements. That’s pretty much it.

I hope this proves helpful.

Regards,
Markus
Ranorex Support Team

Re: Adding/Appending new rows an existing csv file

Posted: Thu Jun 28, 2012 2:25 pm
by nandeesh
Hi,

Thanks Markus.