Copy link to clipboard
Copied
I have a file whcih gets downloaded and then read and inserted into the database. The problem is when I read the belwo records below which should be 3 indexes, it breaks the index with the comma delimted file into 5 indexes.
"","","Wonderful Expanded Cape, With 4/5 Bedrooms 2 Full Bths. Eik, Lr,Great Place, New"
How can I replace the comma delimited in the file when downloaded and the use that delimiter in my ListToArray .
<cfloop index="ind" list="#readlistings#" delimiters="#chr(13)##chr(10)#">
<cfset i=ListToArray(ind, ",", true) />
<cfoutput>
#i[4]#
<br><br>
</cfoutput>
</cfloop>
To retrieve the data's embedded in quotes, u can use the function in the following url by passing ur string conataining commas as argument.
Copy link to clipboard
Copied
To retrieve the data's embedded in quotes, u can use the function in the following url by passing ur string conataining commas as argument.
Copy link to clipboard
Copied
plz refer
http://www.bennadel.com/blog/274-Java-Exploration-in-ColdFusion-java-io-LineNumberReader.htm
Copy link to clipboard
Copied
If the delimiter commas are surrounded by double quotes, you have several options.
1. After uploading the file, read it with cfhttp instead of cffile. The text qualifier attribute will be helpful.
2. Set some variable to "," and use it as your delimiter.
3. Replace the "," with a single character, like a pipe.
Note that for options 2 and 3, you'll have to do something about the leading and trailing quotes. For all three options, you'll need a plan for dealing with empty fields.
Copy link to clipboard
Copied
Dan,
Do you have an example of this?
Copy link to clipboard
Copied
Make sure that the directory containing your file allows http requests. It's really annoying when it doesn't.
<cfhttp url="your file"
name = "YourQuery"
columnnames = "f1,f2,f3"
delimiter = ","
textqualifier = """">
<cfdump var = "#YourQuery#">