cancel
Showing results for 
Search instead for 
Did you mean: 

Import Dates with data loop and CSV

SOLVED
Highlighted
New Contributor

Import Dates with data loop and CSV

Hey there,

I'm trying to figure out how to Import Dates from a CSV file into Testcomplete. I got a huge Problem when the Date has a starting "0" because I think Testcomplete is importing the Date as a Number. 

I'm from Germany and I must use the following Date Format in the tested program.  (DD.MM.YYYY)

For example:
CSV-File                                                             Imported
01.01.2020                                                       1012020
12.01.2020                                                       12012020
’01.01.2020’                                                     ’01.01.2020’
I need:
01.01.2020                                                       01.01.2020
or                                                                       01012020

I already tried the Schema.ini file but it's not working for me.


I hope you can help me.
Greetings

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
New Contributor

I made a small Workaround now  and my Problem is done with it.

function Excel_Loop()
{
  //Runs the "EXCEL" tested application.
  TestedApps.EXCEL.Run(1, true);
  Project.Variables.csv2207.Reset();
  for(; !Project.Variables.csv2207.IsEOF();)
  {
    csvimporttest = Project.Variables.csv2207.Value("F5");
    test123 = String(Project.Variables.csv2207.Value("F5"));
    laengecsv = test123.length;
    if (laengecsv < 8  {
    csvimporttest = "kleiner 8" + "   0" + Project.Variables.csv2207.Value("F5") + "   " + laengecsv
    }
      else {
        csvimporttest = "größer 7" + "  " + Project.Variables.csv2207.Value("F5") + "   " + laengecsv
      }
   //csvimporttest = Project.Variables.csv2207.Value("F5") + "     " + laengecsv
    //csvimporttest = "Test123" +  Project.Variables.csv2207.Value("F5")
 
    Aliases.EXCEL.wndXLMAIN.XLDESK.Mappe1.Keys(csvimporttest);
    Aliases.EXCEL.wndXLMAIN.XLDESK.EXCEL6.Keys("[Enter]");
    Project.Variables.csv2207.Next();
  }
}


I imported the data as before but then i watched at the length of the importet value and added a leading 0 when the length is 7.

Thanks for your Replys

View solution in original post

5 REPLIES 5
Community Hero
Highlighted
Community Manager

Thank you for providing guidance Marsha!

 

@RKU_AVO was this article helpful?


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
New Contributor

Hey,
thanks for the respond but this is not working for me because the data is converted while Import.

2020-07-28 12_14_15-Data-Driven Loop.png

As you can see in the Field F5 the Dates are converted to numbers.
The normal data is:
01.01.2020
12.01.2020

Thanks

Highlighted
Community Hero

If you already have a string, then you can use aqString methods to pick the string apart and rebuild it in the format you want.

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/methods.html

Tags (1)
Highlighted
New Contributor

I made a small Workaround now  and my Problem is done with it.

function Excel_Loop()
{
  //Runs the "EXCEL" tested application.
  TestedApps.EXCEL.Run(1, true);
  Project.Variables.csv2207.Reset();
  for(; !Project.Variables.csv2207.IsEOF();)
  {
    csvimporttest = Project.Variables.csv2207.Value("F5");
    test123 = String(Project.Variables.csv2207.Value("F5"));
    laengecsv = test123.length;
    if (laengecsv < 8  {
    csvimporttest = "kleiner 8" + "   0" + Project.Variables.csv2207.Value("F5") + "   " + laengecsv
    }
      else {
        csvimporttest = "größer 7" + "  " + Project.Variables.csv2207.Value("F5") + "   " + laengecsv
      }
   //csvimporttest = Project.Variables.csv2207.Value("F5") + "     " + laengecsv
    //csvimporttest = "Test123" +  Project.Variables.csv2207.Value("F5")
 
    Aliases.EXCEL.wndXLMAIN.XLDESK.Mappe1.Keys(csvimporttest);
    Aliases.EXCEL.wndXLMAIN.XLDESK.EXCEL6.Keys("[Enter]");
    Project.Variables.csv2207.Next();
  }
}


I imported the data as before but then i watched at the length of the importet value and added a leading 0 when the length is 7.

Thanks for your Replys

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get properties of a web page element

See replies!

Compare images using the Region Checkpoint

See replies!

Compare HTML table with Excel file and correct data in Excel file

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!
Top Kudoed Authors