cancel
Showing results for 
Search instead for 
Did you mean: 

Input data has been trancated while taking from csv

Super Contributor

RE: Input data has been trancated while taking from csv

Thanks Andrey,



1- I am using TestComplete 8.7

2- I have save csv file  as incoding - ANSI

3- I have debug the code but still I am facing same issue.



Please refer attached csv file.



Yes ! we can Use Excel and solve the issue and we did,  but due to some limitation in Test Data,  we approched csv file.



Well Thanks for your help !!
Community Manager

RE: Input data has been trancated while taking from csv


Hi Ravi,


 


Have you tried specifying the type for each column? Here is the code I specified in the Schema.ini file (I mentioned about it earlier):


[Test.csv]


Format=Delimited(,)


CharacterSet=ANSI


Col1=CurrentNumber Double Width 20


Col2=NewNumber Double Width 20


 


 


 


In TestComplete 9.31, I successfully executed the following sample code that reads data from a CSV file:




//JScript


function CSVDriverExample()


{


  DDT.CSVDriver("Test.csv" );


  while (! DDT.CurrentDriver.EOF())


   {


    Log.Message(aqConvert.VarToFloat(DDT.CurrentDriver.Value(0)));


    Log.Message(DDT.CurrentDriver.Value(1));


    DDT.CurrentDriver.Next();


      


    }


  DDT.CloseDriver(DDT.CurrentDriver.Name);


}



---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Community Leader

Re: Input data has been trancated while taking from csv

Hi @Ravik 

 

Does the textbox you are trying to type into have a max length?  If TC detects that the string you are trying to enter is longer than the max length of the actual text box, that is the kind of message you get.  Even if the textbox has a max length of 16, you may still run into an issue because...

TC uses the information supplied by Microsoft on the datatype it detected in the column - in other words, Microsoft guesses, TC believes it.  This means a CSV field with 16 numbers in won't be interpreted as a text, but rather a number.  This number is larger than an integer though, so ends up being changed to scientific notation e.g. 1.2345678901234E15  That value is interpreted as a string longer than 16 characters.  Here two potential ways around this:

 

1. Use a XLS/XLSX file.  That way you can add the single qoute in front of the number e.g. '1234567890123456 and TC will read it as a literal string.  If you use source control this isn't the best option though.  There is no way to compare the two files.  If you are using spreadsheets as data, I would recommend sticking to CSV

2. Use a CSV in conjuction with schema.ini

 

Microsoft documentation on schema.ini

 

You need to place the file in the same folder as the CSV and it will override the way TC interprets it from Microsoft.

 

You should only need to specify the columns that don't behave, so in your case, you could have a CSV with 10 columns, but you only need to specify 2.  So, for example:

 

[MyFile.csv]
Format=CSVDelimited
ColNameHeader=True
MaxScanRows=5
Col9=NumberIn Text
Col10=NumberOut Text

Hope that helps


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors