Advertisement

06.16.2004 at 12:28PM PDT, ID: 21027934
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Replace all commas with ","...unless the comma is already between quotes?

Asked by Cardguy in ColdFusion Application Server

Tags: ,

OK, since Excel incorrectly formats CSV files (it does not put quotes around all fields, which is the standard), ODBC has problems with data formats.  I won't bore you with the details here.

Anyway, our solve was to try and correct the CSV file before we query it.  So, this is what we need to do.

Here are two sample data sets we need to convert:

DataSet 1
-----------
Column1,Column2,Column3
aaaaa,bbbbb,ccccc
ababa,"baba, baba",cdcdcd
ffffff,,dddddd

(notice that the 2nd row, 2nd column has quotes around the field since there is a comma in that field)

DataSet 2
-----------
"Column1","Column2","Column3"
"ssssss","tttttt","uuuuuu"
"vvvvvvvv","wwwwww","xxxxxx"
"yyyyy","zzzzzz","1111111"

(this data set is properly formated, with quotes around all fields)

We will get CSV files in both formats, so we need to account for both.

So, what we need to do is:
- change all commas to "," unless that comma is already between quotes.  Then, you would have to replace ," with ","...as in the DataSet 1
- add " to the beginning and end of the line
- do the above steps only if the file is not formatted like Dataset 2


Is this possible?  I don't even know where to begin on having CF perform a find and replace this complex.
Start Free Trial
[+][-]06.16.2004 at 12:45PM PDT, ID: 11328193

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.16.2004 at 12:47PM PDT, ID: 11328216

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.16.2004 at 01:30PM PDT, ID: 11328673

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.16.2004 at 02:16PM PDT, ID: 11329059

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.16.2004 at 03:16PM PDT, ID: 11329485

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: ColdFusion Application Server
Tags: replace, comma
Sign Up Now!
Solution Provided By: Tacobell777
Participating Experts: 4
Solution Grade: A
 
 
[+][-]06.17.2004 at 02:12AM PDT, ID: 11332799

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.17.2004 at 05:24AM PDT, ID: 11333781

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44