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.
Adding/Appending new rows an existing csv file
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Adding/Appending new rows an existing csv file
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
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
You do not have the required permissions to view the files attached to this post.
Re: Adding/Appending new rows an existing csv file
Hi,
Thanks Markus.
Thanks Markus.