Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Appending from csv files
Message
De
17/02/2015 12:17:28
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01615469
Message ID:
01615483
Vues:
25
>>>>>>You must use the specific file name. You can use ADIR to get a list of files then loop though the array.
>>>>>>
>>>>>>
>>>>>>>In my directory j:\interlinkhayes are a number of csv files all of the same format delimited with commas
>>>>>>>
>>>>>>>If I append just 1 file as follows APPEND FROM j:\interlinkhayes\INT12345.csv DELIMITED WITH CHAR , I have no problems
>>>>>>>
>>>>>>>But if I try APPEND FROM j:\interlinkhayes\INT*.csv DELIMITED WITH CHAR , I get errors
>>>>>>>
>>>>>>>What is the simplest code for appending multiple files with a skeleton INT*.CSV
>>>>>
>>>>>Thanks
>>>>>
>>>>>Can you show me the code to get a list of all the files
>>>>>
>>>>>Much appreciated
>>>>
>>>>
>>>>lcDir = ' j:\interlinkhayes\'
>>>>lcSkeleton = 'int*.csv'
>>>>lnFiles = adir(laFiles, lcDir + lcSkeleton)
>>>>for lnX = 1 to lnFiles
>>>>   append from (lcDir + laFiles(lnX,1) ...
>>>>Endfor
>>>
>>>
>>>
>>>But this code appears to work - am I correct?
>>>
>>>gnumber = ADIR(gaDatabase, '*.csv') && Create array
>>>
>>>gnumber=1
>>>FOR x=1 to gnumber
>>>store gadatabase(x,1) TO muc
>>>
>>>muc="j:\interlinkhayes\"+muc
>>>WAIT WINDOW muc
>>>SELECT hayes
>>>APPEND FROM &muc DELIMITED WITH CHAR ,
>>>
>>>next
>>
>>To be honest, I have problems understanding your code. My code DOES work, once you have fixed your typos. And stay away from macros, &, as in &muc. Use (muc) instead, it's safer and faster.
>
>Tore at the risk of being a real pain what typos are there in your code which prevents it from working for me?

None that I am aware of, although I didn't include " DELIMITED WITH CHAR , " in the Append line, since I knew you would spot that omission. I suggest that you add a "Wait laFiles(lnX,1)" line inside the loop, to make sure that the right files are processed.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform