Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy to file type csv
Message
From
18/05/2007 10:04:05
James Beerbower
James Beerbower Enterprises
Hochheim Am Main, Germany
 
 
To
18/05/2007 09:44:52
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01226670
Message ID:
01226716
Views:
28
Hi Gaylen,

Glad the copy delimted works for you. However copy delimited may not do every sort of CSV that customers want. If you should have the misfortune to encounter the weird ones you can also use low level file functions to get the precise requirements.

For example:
lparameters lcFile,lcOutputFile

afields(laFields,m.lcFile)
erase (m.lcOutputFile)
m.lnHandle=fcreate(m.lcOutputFile)
m.lcSeparator = ";"

local m.i
select (lcFile)

scan
	lcLine = ""
	for i = 1 to alen(laFields,1)
			m.lxValue =evaluate(laFields(i,1))
		if !empty(m.lxValue)
			m.lcValue = ALLTRIM(transform(m.lxValue))
			m.lcValue = strt(strt(STRTRAN(m.lcValue,"'",""),["],""),[,],"")
			m.lcValue  = ["]+alltrim(m.lcValue) +["]
		else
			m.lcValue = ""
		endif	
		m.lcLine = m.lcLine+m.lcValue+m.lcSeparator
	endfor
	m.lcLine = substr(m.lcLine,1,rat(m.lcSeparator,m.lcLine)-1)
	fputs(m.lnHandle,m.lcLine)
endscan
fclose(m.lnHandle)
select (m.lnSelect)
Mind you, copy to... -> filetostr -> manipulate -> strtofile is another way to skin the cat.

>Thanks Edward
>
>That works just fine. It eliminates the header and encloses the text fields with " ".
>
>To the others also that quickly responded I say
>
>Thanks!!
>Gaylen
>
>>>I need to create a comma delimited file from a table with " " around the alpha fields. Copy to xxx type csv works fine except it creates a header record of the fields. The bank wants the csv file without the header.
>>>
>>>Any quick fixes for this.
>>>
>>>Gaylen
>>
>>Try COPY TO ... DELIMITED
James Beerbower
James Beerbower Enterprises
Frankfurt, Deutschland
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform