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

Removing the Comma delimiter with something else in a File download

Contributor ,
Jul 12, 2009 Jul 12, 2009

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>

680
Translate
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

Deleted User
Jul 12, 2009 Jul 12, 2009

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.

http://www.cflib.org/udf/CSVtoArray

Translate
Guest
Jul 12, 2009 Jul 12, 2009

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.

http://www.cflib.org/udf/CSVtoArray

Translate
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
Contributor ,
Jul 12, 2009 Jul 12, 2009

plz refer

http://www.bennadel.com/blog/274-Java-Exploration-in-ColdFusion-java-io-LineNumberReader.htm

Translate
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 ,
Jul 13, 2009 Jul 13, 2009

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.

Translate
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
Contributor ,
Jul 13, 2009 Jul 13, 2009

Dan,

Do you have an example of this?

Translate
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 ,
Jul 13, 2009 Jul 13, 2009
LATEST

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#">

Translate
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