Adding/Appending new rows an existing csv file

Ask general questions here.
nandeesh
Posts: 14
Joined: Tue Jun 12, 2012 12:07 pm

Adding/Appending new rows an existing csv file

Post by nandeesh » Fri Jun 22, 2012 11:30 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Adding/Appending new rows an existing csv file

Post by Support Team » Mon Jun 25, 2012 2:09 pm

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
Attachments
Example.zip
(303.41 KiB) Downloaded 1248 times
.
Image

nandeesh
Posts: 14
Joined: Tue Jun 12, 2012 12:07 pm

Re: Adding/Appending new rows an existing csv file

Post by nandeesh » Thu Jun 28, 2012 2:25 pm

Hi,

Thanks Markus.