APPEND FROM (lcSource) TYPE DELIMITED WITH TAB
Would seem to do the trick, however when I export a cell that contains a
double quoted piece of text, it becomes (for example)
"He said ""one day the documentation will be correct"""
Let us Ignore the fact that excel makes no mention that it will enclose
quoted text in quotes (it says it will if it contains commas, which is
equally pointless - tab delimited means delimited with tabs, who cares
about quotes). Foxpro appears to take each pair of double quotes and makes
each a seperate field. As a result the above text translates into three
fields.
The WITH CHARACTER doesn't work with WITH TAB (or BLANK). Does anyone know
a fix/work around? If you would like to offer a different solution, the
excel -> foxpro append requires that an excel date becomes a foxpro date
(doesn't work directly), that a excel time becomes a text string, and that
a short free form piece of text that is restricted only by excel (tab
delimited looked good, because you can't get tabs in a cell).
Thanks in advance for any consideration.
Alan.
I saved my spreadsheet as type csv. [CSV (Comma delimited) (*.csv) choice in
Excel save as]
Then I use APPEND FROM MyCsvTable.csv DELIMITED.
Fox converts the data types unless it's impossible. ("ABC" into a numeric
field.)
--
Cindy Winegarden
Duke Children's Information Systems
Duke University Medical Center
cindy.wi...@duke.edu
<snip>
[..]
Mistake on my part in this section: Excel dates work fine, excel times get
converted to a date: 19000100 with dBase III and IV.
dBase II gets converted to 0.
> >The WITH CHARACTER doesn't work with WITH TAB (or BLANK). Does anyone
He said "one day the documentation will be correct"
To:
"He said ""one day the documentation will be correct"""
When foxpro imports that, It creates three seperate fields. Maybe the fact
that
the field that follows this freeform text is also a text field doesn't
help.
Here is a sample from the excel spread sheet if anyone want to try to get
it to work:
Initials % Date % Start % End % Description % Account
ADP % 02/26/1999 % 09:00 % 09:30 % Work, again, on "Excel" % SOFT
ADP % 02/26/1999 % 09:30 % 10:00 % Reply to kind posters % SOFT
Fields Excel Foxpro
Initials Text C(3)
Date Date D
Start hh:mm C(10)
End hh:mm C(10)
Desc. Text C(80)
Acct. Text C(8)
Cindy Winegarden <cindy.wi...@duke.edu> wrote in article
<#abj#4SY#GA....@uppssnewspub04.moswest.msn.net>...
> Alan,
>
> I saved my spreadsheet as type csv. [CSV (Comma delimited) (*.csv) choice
in
> Excel save as]
>
> Then I use APPEND FROM MyCsvTable.csv DELIMITED.
>
> Fox converts the data types unless it's impossible. ("ABC" into a numeric
> field.)
>
> --
> Cindy Winegarden
> Duke Children's Information Systems
> Duke University Medical Center
> cindy.wi...@duke.edu
>
> <snip>
Alternately, if you are just doing this once, use the formatted text, (space
delimited) (*.prn) option. You will have to figure out how long each field
is, it is based on the width of the excel column, and if you did it again
later, with longer columns, the fields will be longer. That is why I would
only do this if you are going to convert once, or at least, not very often.
Alan Porter wrote in message <01be6198$ded07800$0601a8c0@digital-3100-2>...
You may wish to consider doing some pre/post processing
1. Read each line of the input file using LLF functions into a variable (say
lcLine)
1a. lcLine = strtran(lcLine, [""], [%%%%])
1b. Write lcLine to a new text file (say NewFile.txt)
2. Append from NewFile delimited with TAB (into your import table)
3. Replace Desc with strtran(desc, [%%%%], ["]) for ! eof()
You could also use the filetostr if you're using VFP6
1. lcOldValue = FILETOSTR(inputFile)
1a. lcNewValue = strtran(lcOldValue, [""], [%%%%])
1b. STRTOFILE(lcNewValue, 'NewFile.txt', .f.)
2. Append from NewFile delimited with TAB (into your import table)
3. Replace Desc with strtran(desc, [%%%%], ["]) for ! eof()
Note that you would probably be better served if you didn't use DESC as a
field name - it'll confuse the SQL parser no end! (Try DESCR instead)
Cheers,
--
Andrew Coates
Civil Solutions
http://www.civilsolutions.com.au/
a.co...@civilsolutions.com.au
PGP Public Key on MIT Server
I've written a program a while ago to strip characters which might
interfere with the field delimiter, this works fine (for me)
with plain text dumps.
* Set default to directory containing the source files
SET DEFA TO C:\TMP\DUMP\COSTCHRG
*
* The extension of the source files
Lext=[*.D]
*
* The destination directory
Fdest=[C:\TMP\DUMP\COSTCHRG\AA\]
*
* The delimiter used between the Fields
FDelim=[^]
*
* The delimiter used for carachter fields
CDelim=["]
*
* The new delimiter for use between the fields
NFDelim=[ ]
*
* The new value for the character which was equal to the field delimiter
NewValue=[&]
FFILE=ADIR(FF,Lext)
FOR II = 1 TO FFILE
OLDF=FOPEN(FF(II,1))
FSIZE = FSEEK(OLDF,0,2)
NEWF=FCREATE(FDEST+FF(II,1))
=FSEEK(OLDF,0)
LC=FGETS(OLDF,1000)
DO WHILE NOT EMPTY(LC)
FIN=[]
LCL=ALLTR(FDELIM)+ALLTR(LC)
FOR I = 1 TO LEN(LCL)
DPOS1=AT(FDELIM,LCL,I)
DPOS2=AT(FDELIM,LCL,I+1)
NUMER=OCCURS(CDelim,SUBSTR(LCL,DPOS1,DPOS2-DPOS1))
IF NUMER>0
REMO=SUBSTR(LCL,DPOS1+2,DPOS2-DPOS1-3)
LPO=STRTRAN(SUBSTR(LCL,DPOS1+2,DPOS2-DPOS1-3),CDelim,NewValue)
LCL=STRTRAN(LCL,REMO,LPO,1,1)
REMO=STRTRAN(SUBSTR(LCL,DPOS1,DPOS2-DPOS1),CDelim)
ELSE
REMO=STRTRAN(SUBSTR(LCL,DPOS1,DPOS2-DPOS1),CDelim)
ENDIF
IF NOT EMPTY(REMO)
IF NUMER#0
FIN=FIN+STRTRAN(REMO,FDELIM,FDELIM+CDelim)+CDelim
ELSE
FIN=FIN+REMO
ENDIF
ENDIF
ENDFOR
LFIN=LEN(FIN)
FIN=SUBSTR(FIN,2,LFIN-1)
LCS=FIN
LCS=STRTRAN(LCS,FDELIM,NFDelim)
=FPUTS(NEWF,LCS)
LC=FGETS(OLDF,1000)
ENDDO
=FCLOSE(OLDF)
=FCLOSE(NEWF)
ENDFOR