Thought I better clarify:
Thought I better clarify:
Rules for a csv file are that each 'field' is separated by a comma (,) and
the end of each 'record' is terminated by a carriage return.
If a field contains a carriage return then you enclose the field in " and
" - quote marks. (Sorry apostrophe was wrong term to use).
So if I have this record:
1,1 The Avenue, New York, 345666,"hello in this field we have a carriage
return
more text here", 0233-444-7777,blue
If I use
char *fgets(char *s, size_t n, FILE *stream);
Then fgets gets to carriage return between two " "'s and I only half part of
the record.
I can obviously check if odd number of "'s in string and if so get to next
carriage return - but it does seem tricky getting it just right. I wondered
if anyone had come across this sort of thing before and how they got round
it?
Angus
"Someone" <no****@gmail.comwrote in message
news:ee*******************@news.demon.co.uk...
Hello
Using the c file io functions if reading a csv file there is a problem if
a
field contains an embedded carriage return. So I can check for apostrophe
pairs but processing does seem a bit of a struggle. Has anyone got a
robust
algorithm or functions to use to reliably get a whole row of text from a
csv
file even if some fields contain embedded carriage returns?
Angus