Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
pgalvezt
Specialist
Specialist

Visual Fox Pro

Hi, Currently Im loading manually dbf files. All dbf files has the same structure. I set the fields into the script according customer requirements.

So... Finally Im loading this:

//////Site 1//////
Bases:
OLEDB CONNECT TO [Provider=VFPOLEDB.1;Data Source=e:\datos externos\2011\12_diciembre;Mode=Share Deny None;Extended Properties="";User ID="";Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN="";DELETED=True;CODEPAGE=1252;MVCOUNT=16384;ENGINEBEHAVIOR=90;TABLEVALIDATE=3;REFRESH=5;VARCHARMAPPING=False;ANSI=True;REPROCESS=5];
LOAD *, 'Site1' as Source;
LOAD
  ntarj                                                                                 as Num_Tarjeta_OP,
    num(`cod_bloq`)                                                              as Cod_Bloqueo,
    if(num(`cod_bloq`) <> 8, 'Vigente','Castigada')                    as Vigente_Castigo,

      #deudat                                                                         as Deuda_Total,#
    estado                                                                           as Estado,
     MonthName(Date(`td_corte2`,'MMM-YY'))                        as Periodo,

SQL SELECT *
FROM `btcc11_21`
Where estado =1 And deudat <> 0;

//////Site 2//////

OLEDB CONNECT TO [Provider=VFPOLEDB.1;Data Source=e:\datos externos\2012\01_Enero;Mode=Share Deny None;Extended Properties="";User ID="";Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN="";DELETED=True;CODEPAGE=1252;MVCOUNT=16384;ENGINEBEHAVIOR=90;TABLEVALIDATE=3;REFRESH=5;VARCHARMAPPING=False;ANSI=True;REPROCESS=5];

LOAD *, 'Site2' as Source;

LOAD

  ntarj                                                                                 as Num_Tarjeta_OP,

    num(`cod_bloq`)                                                              as Cod_Bloqueo,

    if(num(`cod_bloq`) <> 8, 'Vigente','Castigada')                    as Vigente_Castigo, 

      #deudat                                                                         as Deuda_Total,#
    estado                                                                           as Estado,
     MonthName(Date(`td_corte2`,'MMM-YY'))                        as Periodo,

SQL SELECT *
FROM `btcc11_40`
Where estado =1 And deudat <> 0;

//////Site 3//////

OLEDB CONNECT TO [Provider=VFPOLEDB.1;Data Source=e:\datos externos\2012\02_Febrero;Mode=Share Deny None;Extended Properties="";User ID="";Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN="";DELETED=True;CODEPAGE=1252;MVCOUNT=16384;ENGINEBEHAVIOR=90;TABLEVALIDATE=3;REFRESH=5;VARCHARMAPPING=False;ANSI=True;REPROCESS=5];

LOAD *, 'Site3' as Source;

LOAD

  ntarj                                                                                 as Num_Tarjeta_OP,

    num(`cod_bloq`)                                                              as Cod_Bloqueo,

    if(num(`cod_bloq`) <> 8, 'Vigente','Castigada')                    as Vigente_Castigo, 

      #deudat                                                                         as Deuda_Total,#
    estado                                                                           as Estado,
     MonthName(Date(`td_corte2`,'MMM-YY'))                        as Periodo,

SQL SELECT *
FROM `btcc11_40`
Where estado =1 And deudat <> 0;

And So on.... Every time when a dbf fall into the folder Im connecting to the new file and I create a new "Site". But I need left this automate. So I have this:

Sub Busqueda (Root)
     For Each Ext In 'dbf' // Búsqueda para el actula directorio
          For Each File In FileList (Root & '\*.' & Ext)
                    Files:
                     Load '$(File)' as Name,
                     FileTime('$(File)') as FileTime,
                     RangeSum(Peek('FileCount'), 1) as FileCount
                     Autogenerate 1;
          Next File
     Next Ext

     For Each Dir In DirList (Root & '\*.dbf') // Búsqueda en SubDirectorios
          Call Busqueda (Dir)
     Next Dir

End Sub

Call Busqueda ('E:\Datos externos\2012\'); // Starting point

MostRecentFileName:
//FIRST 10
Load Name AS MostRecentFileName
Resident Files
Order by FileTime Desc;

Let vFileToLoad = FieldValueCount('MostRecentFileName');

For each file in FieldValueList('MostRecentFileName')

MostRecentdata:
OLEDB CONNECT TO [Provider=VFPOLEDB.1;Data Source=e:\datos externos\2012\;Mode=Share Deny None;Extended Properties="";User ID="";Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN="";DELETED=True;CODEPAGE=1252;MVCOUNT=16384;ENGINEBEHAVIOR=90;TABLEVALIDATE=3;REFRESH=5;VARCHARMAPPING=False;ANSI=True;REPROCESS=5];

SELECT *
FROM $(file);

I`ve eliminated 02_Febrero From in the string of connection (e:\datos externos\2012\02_Febrero) so I have this now e:\datos externos\2012\ But doesn't work.

If you need more details let me know please.

41 Replies
pgalvezt
Specialist
Specialist
Author

Any Help?

Thanks

flipside
Partner - Specialist II
Partner - Specialist II

I cannot help with OLEDB as I don't have the drivers installed, but I have connected to VFP files previously using ODBC drivers using a System DSN which was pretty easy. Just point the driver to one of the files in the directory and you can select any other file in that folder as though it was a database table.

If I recall I had to have both the DBF and CDX files (and for some tables the FPT file).

Could be worth trying ODBC to see if it's an OLEDB issue.

flipside

pgalvezt
Specialist
Specialist
Author

Hi,

How do you do for take all dbf files? (I can not take all dbf files with just one selection) When I try to take all files QlikView shows me the complete directory but when I put Select Qlikview just let me choose just one base for each connection. Could you please advice me about this type of connections?

Thank you!

pgalvezt
Specialist
Specialist
Author

Any Help?

pgalvezt
Specialist
Specialist
Author

Anyone?

Thanks

rbecher
MVP
MVP

Hi,

you need to move the SELECT inside the For Each File in FILELIST loop.

There is no FieldValueList. It wouldn't needed furthermore..

- Ralf

Astrato.io Head of R&D
pgalvezt
Specialist
Specialist
Author

Could you provide more specific details first time that I working with VFP. I put an example test.

Thanks.

rbecher
MVP
MVP

//something like this:

ODBC CONNECT TO [Visual FoxPro Tables];

For Each File In FileList ('E:\Modelos\Solventa\Tarjetas de Credito\Datos externos\Bases_TC\2012\*.dbf')

        

    Let vTableName = subfield(mid('$(File)', index('$(File)', '\',-1) +1), '.dbf', 1);

     

    TableContent:

    SELECT *

    FROM $(vTableName);

Next File

Astrato.io Head of R&D
pgalvezt
Specialist
Specialist
Author

I realized the changes into my Qvw Example and Appears This: See the attached file please.