Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Large tables
Message
 
 
À
11/07/2000 19:32:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00390984
Message ID:
00391167
Vues:
12
>I am currently using low level file functions to do this. The file I am reading in is 65 Meg in size and it has taken over 4 hours to convert it. I was looking for a faster way to perform the conversion and grouping of information. I'm not sure about your question about if the last two fields are separated. Each record in the text file has a carriage return and line feed at the end of the record. I would figure that I should be able to read a text file into a tabel via SDF with no problem as long as those conditions were met. Any other sugestions??
>Mike

Hi Mike,

Not sure, if it helps, but look at the program, we used for similar (not exactly) purposes...
*--------------------------------------------------------------------------
* -- Program to remove character field delimiters from a set of text files.
* --   Required for Website Extract - Website Sybase import program uses delimited records;
* --   but can have no character field delimited.  VFP can't produce this, hence this 'fix'
*--------------------------------------------------------------------------
lparameter cdbfname

local lntxtfiles, lcPattern, lnPos, i,  lcFileName, lnSelect, ;
     lcSendFileName, lnFileSize, lcCurState, lcIssWeek, lcString, lni

if type('oJC')='O' && oJC was properly instantiated
     lcCurState=oJC.CurState
     lcIssWeek=oJC.IssWeek
else
     lcCurState='MA' && For stand-alone testing
     lcIssWeek='0015'
endif

set safety off
lnSelect=select()
wait window nowait "Running RemFldDelim Special Program"

*--------------------------------------------------------------------------
* -- Calculate the list of txt file names from the cdbfname (ojc.outtable)
*--------------------------------------------------------------------------
lcPath=justpath(cdbfname)+'\'
lnPos=rat('\',cdbfname)
lcPattern=lcPath +'???'+substr(cdbfname,lnPos+4)
lcPattern=forceext(lcPattern,'txt')

lntxtfiles=adir(laTxtFiles, lcPattern) && Retrieve list of text files

*--------------------------------------------------------------------------
* -- loop through the array and perform string transformations in each text file
*--------------------------------------------------------------------------
create cursor lcTempCursor ;
     (WorkField M)
append blank

for i=1 to lntxtfiles

     lcFileName=lcPath+laTxtFiles[i,1]
     lnFileSize=laTxtFiles[i,2] && File Size
     lcSendFileName = lcPath+lcCurState+'\'+left(laTxtFiles[i,1],4)+'.txt'
     wait window nowait 'Preparing file '+lcSendFileName
     if file(lcSendFileName)
          erase (lcSendFileName)
     endif

     if lnFileSize< 5000000 && Relatively small files <4,5MB

          append memo WorkField from (lcFileName) overwrite
          if !empty(alltrim(WorkField))
               replace WorkField with strtran(WorkField,'"','')
               copy memo WorkField to (lcSendFileName)
          endif

     else && For huge files this technique doesn't work, let's try something different
          wait window nowait 'Preparing big file '+lcSendFileName+;
               chr(13)+'Size '+alltrim(str(round(lnFileSize/1024,0)))+' KB'+ ;
               chr(13)+'Please, wait...'

          local inFile, outFile, lcBuffer     

          inFile= fopen(lcFileName) && Open a file
          outFile=fcreate(lcSendFileName) && Create a file

          do while !feof(inFile)
               lcBuffer=fgets(inFile,1000) && Get the string
               lcBuffer= strtran (lcBuffer,'"','')
               =fputs(outFile,lcBuffer)
          enddo

          =fclose(inFile)        && Close In file
          =fclose(outFile)       && Close Out file

     endif

next
use in lcTempCursor

select (lnSelect)
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform