login about faq

Hi Matt and everyone,

I am using csv to process a csv data file form my customer. The file is not very large, about 4000 lines. It going well until CSV tried to slpit on a comma within a quoted block. My guess is that because there is a space on both sides of the comma, CSV assumed this was a new cell.

Here is a sample of the data. Please let me know what to do as a work-around.

Thanks, Erik

"...","LIFTING , PULLING OVER TIME","..."
"...","Joe was bailing cardboard , slipped on cardboard and fell","..."

asked Jan 28 at 20:38

emartinson's gravatar image

emartinson
148162030


I tested using the latest version of Chilkat, and found no problem. Here's my test program:

    CkCsv csv;

const char *testName = "qa_csvCommaProblem";

csv.put_HasColumnNames(false);

bool success = csv.LoadFile2("qa_data/csv/commaProblem.csv","utf-8");
if (!success)
{
printf("%s\n",csv.lastErrorText());
ReturnStatus(testName)
}

printf("NumRows = %d\n",csv.get_NumRows());

printf("%s\n",csv.getCell(0,0));
printf("%s\n",csv.getCell(0,1));
printf("%s\n",csv.getCell(0,2));

printf("%s\n",csv.getCell(1,0));
printf("%s\n",csv.getCell(1,1));
printf("%s\n",csv.getCell(1,2));

ReturnStatus(testName)
link

answered Jan 29 at 09:10

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

You are correct, that was not the cause of the problem. I was the symptom. The real cause of the problem was user error. And this time, not me. It was the data sent to me. The quotation marks in the strings were not properly escaped with 2 "".

(Jan 29 at 13:14) emartinson
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×8

Asked: Jan 28 at 20:38

Seen: 377 times

Last updated: Jan 29 at 13:14

powered by OSQA