Reading a CSV file containing text

Reading a CSV file containig text

Page 1 of 1

7 Replies - 3516 Views - Last Post: 02 February 2011 - 04:53 AM Rate Topic: -----

#1 aj_jack  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-August 10

Reading a CSV file containing text

Posted 19 August 2010 - 06:22 AM

I am reading a csv file conataining text. I am getting the results as expected. For some lines, the text contains a comma(,). I am having problems then as my parsing logic uses comma as a delimiter. I added double quotes(") at both ends of the text. Can I read the whole text enclosed by the double quotes?
Is This A Good Question/Topic? 0
  • +

Replies To: Reading a CSV file containing text

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,661
  • Joined: 23-August 08

Re: Reading a CSV file containing text

Posted 19 August 2010 - 06:25 AM

Post an example of your text, and some code ( use code tags, like this :code: ) and maybe we can help out.
Was This Post Helpful? 0
  • +
  • -

#3 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1112
  • View blog
  • Posts: 4,619
  • Joined: 09-June 09

Re: Reading a CSV file containing text

Posted 19 August 2010 - 07:58 AM

Quote

I am having problems then as my parsing logic uses comma as a delimiter.

Getline has an overload function which includes a parameter for which to parse the line at
Was This Post Helpful? 0
  • +
  • -

#4 Galik  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 23-January 10

Re: Reading a CSV file containing text

Posted 19 August 2010 - 08:22 PM

That is tricky. If every column has the quotes then you could getline() from quote to quote (rejecting every other result).

Otherwise I think you are going to have to write a simple parser that keeps track of opening and closing quotes.
Was This Post Helpful? 0
  • +
  • -

#5 aj_jack  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-August 10

Re: Reading a CSV file containing text

Posted 19 August 2010 - 10:22 PM

View PostGalik, on 19 August 2010 - 07:22 PM, said:

That is tricky. If every column has the quotes then you could getline() from quote to quote (rejecting every other result).

Otherwise I think you are going to have to write a simple parser that keeps track of opening and closing quotes.

Was This Post Helpful? 0
  • +
  • -

#6 aj_jack  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-August 10

Re: Reading a CSV file containing text

Posted 19 August 2010 - 10:30 PM

Hi, thanks for your suggestions.
@Galik, Thank you.I am thinking to change the delimiter character itself from comma(,) to tilde(~), keeping the comma in the text unchanged.
Was This Post Helpful? 0
  • +
  • -

#7 Guest_dulu*


Reputation:

Re: Reading a CSV file containing text

Posted 02 February 2011 - 03:32 AM

View Postrjb, on 02 February 2011 - 03:26 AM, said:

View Postaj_jack, on 19 August 2010 - 06:22 AM, said:

I am reading a csv file conataining text. I am getting the results as expected. For some lines, the text contains a comma(,). I am having problems then as my parsing logic uses comma as a delimiter. I added double quotes(") at both ends of the text. Can I read the whole text enclosed by the double quotes?

heloo
i don' know answer of your question.
but i think u may help solving my question.

i have made a program that reads a csv file ..it is reading properly..
now suppose i have to read column wise. den what i have to do??
for ex:
bho,"1","adf","dfsd",
bhi,"2","dlk","dfd"

now if i want data from second column only den what should i do..??

plz give me ur code if possible.

and one more thing m writin dis code in c language..
Was This Post Helpful? 0

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,661
  • Joined: 23-August 08

Re: Reading a CSV file containing text

Posted 02 February 2011 - 04:53 AM

If you want help with your code, post your code IN CODE TAGS:

:code:

If that's too complicated, read the first link in my signature.

Also, don't use text-speak on our forums; it's rude and disrespectful to our professional atmosphere. Write your posts in actual English.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1