Forum Discussion
- mugheessiddiquiContributorCould you please share CSV data and the code?
- SubbulakshmiFrequent ContributorHi,
The csv file data is having the below row.
ID20,Value20,Automatic,"1,25,26,50",,Value1,Value2,Value3,Value4,Value5,Value6,Value7,Value8,Value9,Value10,Value11,Value12,Value13,Value14,Value15,Value16,,100,JP
Here, we need to retrieve "1,25,26,50" array.
The sample code is as below:
‘Creating the Driver….
DDT.CSVDriver(Projectsuite.Path&"FL_TestSuite_Driver_Testscript.csv")
Set Project.Variables.Inputs=DDT.CSVDriver(Projectsuite.Path&"FL_TestSuite_Driver_Inputs.csv")
.
.
.
.
.
.
‘Reading Value
ColValue=Project.Variables.Inputs.Value("Col1") - mugheessiddiquiContributorHi Deepa
I'm not sure do you have header row in csv or not, I'd recommend to add header column.
e.g
Col1, Col2, Col3, Col4, Col5
ID20,Value20,Automatic,"1,25,26,50","1,29,36,80"
You have to create Schema.ini file at same directory where your CSV file is located.
and replace your CSV file name in first line, (file name must be in square brackets).
[FileName.csv]
Format=CSVDelimited
ColNameHeader=True
MaxScanRows=0
I have not tested by storing DDT.CSVDriver reference in project variable but I hope it will resolve your issue.
Regards
Mughees Siddiqui - SubbulakshmiFrequent ContributorHi,
We are giving column headers also. Whenever it hits ", it returns null. Could you please help us on this.
Regards,
Deepa - SubbulakshmiFrequent ContributorHi,
Can you please help me on this, this is a blocking issue in our project. - karkadilValued ContributorHi Deepa,
I tried working with a file similar to yours and it worked fine. Can you download the file (karkadil.org/1.csv) and try this script. What will it post to the log?
I have also attached the screenshot of the results I got from this function for you to compare.
function testCSV()
{
var csv = DDT.CSVDriver("c:\\1.csv");
while(!csv.EOF())
{
for(var i = 0; i < csv.ColumnCount; i++)
{
Log.Message(csv.Value(i));
}
csv.Next();
}
DDT.CloseDriver(csv.Name);
}
- SubbulakshmiFrequent ContributorHi,
We have already used schema.ini file and the same way, we have used array also..it is not detected as array.. we have added header column also..