• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfsavecontent Situation

Participant ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

Hello Community!

I am writing an export and I am using cfsavecontent to save the values of my main query in a variable.

Let's say that I have first_name|last_name|address <This is where I need to break and move to the next line>

I am using #chr(13)#&#chr(10)# inside the cfsavecontent but the enter is being ignored!

Any thoughts?

P.S: Ian and Adam helped out a lot when I was first creating this export file.

Thanks!

Ysais.
TOPICS
Advanced techniques

Views

2.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Mar 12, 2009 Mar 12, 2009
I found something useful in here:
http://www.bennadel.com/index.cfm?dax=blog:1337.view

Votes

Translate

Translate
LEGEND ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

apocalipsis19 wrote:

>
> Any thoughts?
>
Show some code.

I've never had #chr(13)#&#chr(10)# ignored when they where not supposed
to be ignored.

So without seeing your code, I don't have time to imagine what you could
possible be doing that is so different then the expected way things are
done.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

Here you go:

<cfsavecontent variable="fileContent">
<cfloop index="idx" from="1" to="#getFields.recordcount#">
<cfoutput> #Trim(getFields.email[idx])#|#Trim(getFields.firstname[idx])#|#Trim(getFields.lastname[idx])#|#Trim(getFields.postalcode[idx])#|#Trim(getFields.campaign[idx])#|#DateFormat(getFields.firstordd[idx],'MM/DD/YYYY')#|#getFields.firstordamt[idx]#|#DateFormat(getFields.lastordd[idx],'MM/DD/YYYY')#|#getFields.lastordamt[idx]#|#getFields.htdordcnt[idx]#|#getFields.htdordtot[idx]#|#getFields.annualordcnt[idx]#|#getFields.annualordtot[idx]##Chr(13)##Chr(10)#
</cfoutput>
</cfloop>
</cfsavecontent>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

apocalipsis19 wrote:
> Here you go:
>

Nothing *obviously* out of place there, before I go digging hard, define
'ignored'. How are you experiencing these returns being ignored?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

Well, simple, I want my data to be put into the file in the format:

field1|field2|field3
field1|field2|field3
field1|field2|field3
field1|field2|field3

But my code is generating my data like this:
field1|field2|field3field1|field2|field3field1|field2|field3field1|field2|field3field1|field2|field3

As you can see the line is not braking.

Thank a lot Ian!

Ysais.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

What application are you using to view the generated file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

apocalipsis19 wrote:
> But my code is generating my data like this:
>
> field1|field2|field3field1|field2|field3field1|field2|field3field1|field2|field3
> field1|field2|field3
>

JR Bob Dobbs wrote:
> What application are you using to view the generated file?

To leap forward a bit on where I was trying to lead you and JR caught on
to, *IF* you are looking at your data in a browser as HTML that is what
you are going to see.

HTML - by definition - ignores line feeds and carriage returns and most
other white space characters. So if that is the case, your output is
probably exactly correct and is behaving as it should for the way you
are viewing it.

*IF* that is what you are seeing in the file once it is written and you
view it with some simple text editor or in some manner that does not
ignore white space, then yes, you have some strange behavior going on.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

Please post your code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

I just dumped my variable into the browser, you know the variable that contains the data.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

A web browser will usually not display a line break as a line break, it expects a <br> tag instead.

If you save your fileContent variable to a text file using CFFILE and open this file in a text editor does your content look as expected?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

You are so right JR! I got it!

Thanks Ian and JR!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

apocalipsis19 wrote:
> I just dumped my variable into the browser, you know the variable that contains the data.

I just replied that if you do this, that is how your data is going to
look. HTML by definition ignores line feed and carriage returns.

You need to dump your variable between a set of <pre>...</pre> tags that
tell HTML to *not* ignore these characters OR write the file out and
look at it that way.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

Ok, guys, so let met change the question.

The generated file is 30 megabytes, 300,000 lines.

I need to ftp it and I got the exception:

'putFile operation exceeded timeout'

Have you run into something similar? I already have this: <cfsetting requesttimeout="532000">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

I found something useful in here:
http://www.bennadel.com/index.cfm?dax=blog:1337.view

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

I'd use the export tools designed for my database rather then CF for creating large files or doing other work with large numbers of records.

For example Microsoft SQL Server includes the "Integration Services" feature for this kind of use.
http://www.microsoft.com/sqlserver/2008/en/us/integration.aspx

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2009 Mar 12, 2009

Copy link to clipboard

Copied

LATEST
Thank you JR and Ian!

I appreciate your time and kindness!

Ysais.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation