Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy to file type csv
Message
From
19/05/2007 12:25:04
 
 
To
18/05/2007 10:04:05
James Beerbower
James Beerbower Enterprises
Hochheim Am Main, Germany
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:
01227054
Views:
18
James - your intuition was right. While the delimited command eliminated the header record, the customer has a number of other requirements such as blank fields be recorded as ,, and not ,"",. There shall be no "." in the name such as Ajax Inc. etc. I finally got a file accepted but only after I hacked it with notepad until it made it. The error message they have are such that you can't tell anything other than the record number.

So I appreciate you code as I will be needing to use it to create the file.

Thanks again
Gaylen


>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
Previous
Reply
Map
View

Click here to load this message in the networking platform