Instead of cfsavecontent you can use concatenation which is cleaner. Do something along these lines:
<cfset lineSeperator = chr(10)>
<cfset lineData = ""> <!--- can start with field headers + line seperator in here --->
<cfloop query="dailyDif">
<cfset lineData = lineData & '"#field1info#","#field2#","etc..."'>
<cfif currentrow neq recordcount>
<!--- if not on last record, add seperator for next line --->
<cfset lineData = lineData & lineSeperator>
</cfif>
</cfloop>
<!--- then write lineData to file --->
<cffile action="" file="#filename#" output="#lineData#">
* link regarding java string concatenation might not have come through so here you go if useful in future:
http://coldfusion.sys-con.com/read/42117.htm
http://photos.sys-con.com/story/res/42117/source.html
On 3/2/06, Jamie Tieman
<[EMAIL PROTECTED]> wrote:
I'm sorry, that went right over my head. The file is only 10-20 lines. Is
this what your saying?
<cfset var lineData = "" >
<cfsavecontent variable="dailyDif">
<cfoutput query="work4">
<cfset lineData = lineData 1,22,"GJ","Locations","Daily
Report","#Account#",#Total#/n >
</cfoutput>
</cfsavecontent>
-----Original Message-----
From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]]On Behalf Of
Daniel Roberts
Sent: Thursday, March 02, 2006 8:08 AM
To: [email protected]
Subject: Re: [CFCDev] CSV and blank lines
The problem is that you are including line breaks within the savecontent tag
as part of a loop. Concatenating a string in a loop would probably be the
cleanest solution. If you are building large files with thousands of records
you'll want to check out java string concatenation. Otherwise you can try
just putting multiple tags on the same line to eliminate breaks, or span
comments between tags to comment out the unwanted newline characters.
On 3/1/06, Kenton Gray <[EMAIL PROTECTED]> wrote:
I would try doing a cfloop and do a cfoutput inside that. I've had
similar problems and that seems to always be the easiest way, or as
mentioned you may have to do a cfset and just append it to a variable
with a new line character for each row.
Good luck!
Kenton
On Mar 1, 2006, at 3:24 PM, Jamie Tieman wrote:
> I have a CFC that is trying to create a CSV file, save it to the
> server, and
> then have an FTP program download it.
> Problem is, I end up with blank lines at the end of my file. If I
> put the
> [cfoutput query="work4"] on a separate line, I get a blank line
> first, data,
> and then the 3 blank lines, this way I only get the blank lines at
> the end.
>
> Here's the code:
>
> <cfsavecontent variable="dailyDif">
> <cfoutput query="work4">1,22,"GJ","Locations","Daily
> Report","#Account#",#Total#
> </cfoutput>
> </cfsavecontent>
> <cfset fileDir = "[server directory
> string]#Args.inCompanyNo#\#Args.inYear#\#Left(MonthAsString
> (Args.inMonth),3)
> #\" />
> <cfset filename =
> "#fileDir##arguments.Args.inCompanyNo#_DailyDif_#Left(MonthAsString
> (Args.inM
> onth),3)#.csv"/>
> <cffile action="" file="#filename#" output="#dailyDif#">
>
> And this is what I end up with.
>
> 1,22,"GJ","Locations","Daily Report","036000",-23429.67
> 1,22,"GJ","Locations","Daily Report","050500",- 148080.60
>
>
> And that looks great, BUT it has 3 blank lines at the end even if I
> do a
> cfloop for one record.
>
> Any help would be greatly appreciated,
> Jamie
>
>
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the
> subject of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported by
> CFXHosting ( www.cfxhosting.com).
>
> An archive of the CFCDev list is available at www.mail-archive.com/
> [email protected]
>
>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
