Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
TAB character delimited
Message
 
 
À
20/11/2000 10:17:12
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00443577
Message ID:
00443632
Vues:
12
>Ron,
>
>You can't do it with COPY TO alone, but you can strip out the quotes afterwards by doing:
>
>COPY ALL TO xx DELIMITED WITH TAB
>STRTOFILE(CHRTRAN(FILETOSTR([xx.txt]), ["], []), [xx.txt])
>
>

Hi Cindy,

I think, it would be safe to mention, that this technique would work only for relatively small files. If file is huge, you should use low-level functions to get rid of quotes. Here is example of the program, we use:
********************************************************************
*  Description.......: RemFldDelim - removes character field delimiters from a set of text files.
*  Calling Samples...:
*  Parameter List....: pcDBFName
*  Created by........:
********************************************************************
*--------------------------------------------------------------------------
* -- 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'
*--------------------------------------------------------------------------
lparameters pcDBFName

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 pcdbfname (ojc.outtable)
*--------------------------------------------------------------------------
lcPath=justpath(pcDBFName)+'\'
lnPos=rat('\',pcDBFName)
lcPattern=lcPath +'???'+substr(pcDBFName,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< 16777184 && Relatively small files <4,5MB 16,777,184
          lcString=filetostr(lcFileName)
          lcString=strtran(lcString,'"','')
          strtofile(lcString,lcSendFileName)
*!*               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)
>>Hello every one,
>>
>>Could somebody please help me with the folowing:
>>
>>I have a FoxPro table and i have to create a TAB delimited file from it.
>>When I try this statement: COPY ALL TO xx DELIMITED WITH '' WITH CHARACTER TAB
>>It creates file xx but the fields are not fully correct. It looks like this:
>>
>>"Name" "Address" etc...
>>
>>I don't want to have the double quotes around the words. Could somebody give me the correct statement?
>>
>>I like to see the output like this:
>>
>>Name followed by CHR(9) a none visual character Address , etc...
>>
>>Thanks in advance
>>Ron :)
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform