Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Tomdogggg #1
Perplexed and Confused with CSV conversion from Query
I'm having a little trouble converting a query object into a CSV file.
Everyplace I've ever seen it done, makes a loop and assumes that the COLUMN
NAMES will always be the same. The column names in the query objects that I
want to convert to a CSV file are NOT always the same. Is there a way that I
can loop through the QUERY.ColumnList property and insert POUNDSIGNS around
each word which can be utilized as a dynamic statement later-on in my code?
Tomdogggg Guest
-
Confused with FCS And FMS
I am little confused with the terminology FCS And FMS, I cant see which are the differences. -
Problem with this query string conversion script
I read the article titled A Cure for Arachnophobia by Ben Forta in the CFDJ (http://coldfusion.sys-con.com/read/41702_p.htm). In it was this script... -
OT: :confused;
I have been seeing this all over the board, what the heck is it? Is it an emoticon? Thanks, Drew -
"Operation must use an updateable query".- after conversion to NTFS
You need to set NTFS permissions for IUSR (which weren't in place, obviously, when using FAT32). Right-click the folder, hit sharing and... -
Confused?
Hi Everyone, I'm having a bit of a problem and was wondering if anyone would be able to tell me what I'm doing wrong. the URL to the site I'm... -
mxstu #2
Re: Perplexed and Confused with CSV conversion fromQuery
Everyplace I've ever seen it done, makes a loop and assumes that the COLUMN
NAMES will always be the same.
What do you mean by "assumes ...the column names will always be the same"?
What are you trying to do exactly?
mxstu Guest
-
Tomdogggg #3
Re: Perplexed and Confused with CSV conversion fromQuery
Ok, let's say I'm making a QUERY object into a comma-separated-text(we'll
assume the query is called 'myQuery'):
<cffile action="write"
nameconflict="overwrite"
file="file.csv'"
output="#myQuery.ColumnList#">
<cfloop query="myQuery">
<cffile action="append"
file="file.csv"
output="#column1#, #column2#, #column3#, etc...">
</cfloop>
The problem I'm having, stems from the fact that the columns going into the
comma-separated-text, are assumed to be column1, column2, and column3: What if
this wasn't the case, what if there was NO column1? It would throw an error,
and not make the file correctly. I need to have a dynamically created list of
ALL of the columns in the query so that I can replace the partially dynamic,
but not TOTALLY dynamic statement of 'output="#column1#, #column2#, #column3#,
etc...">' into a comma separated list of the COLUMN NAMES with POUNDSIGNS
around each name.
Tomdogggg Guest
-
BSterner #4
Re: Perplexed and Confused with CSV conversion fromQuery
Something along the lines of...
<cfset filepath = "#GetDirectoryFromPath(ExpandPath("*.*"))#\file.cs v">
<cfset columns = qEmployees.ColumnList>
<cffile action="write"
nameconflict="overwrite"
file="#filepath#"
output="#columns#">
<cfoutput query="qEmployees">
<cfset record = "">
<cfloop list="#columns#" delimiters="," index="colName">
<cfset colVal = qEmployees[VARIABLES.colName]>
#colName#=#colVal#,
<cfset record = record & "#colVal#,">
</cfloop>
<cffile action="append"
file="#filepath#"
output="#record#">
</cfoutput>
BSterner Guest
-
Tomdogggg #5
Re: Perplexed and Confused with CSV conversion fromQuery
Chr(35) Nice job.
Tomdogggg Guest
-
BSterner #6
Re: Perplexed and Confused with CSV conversion fromQuery
Actually, double pound signs would work too and be a better approach.
<cfset record = record & "###colName###=#colVal#,">
BSterner Guest



Reply With Quote

