I have a dataset that may contain double quotes as well as comma anywhere along the length of record. when I delimit the fields(fields embedded in double quote ) with comma i have a problem when there is double quote as part of the field.
e.g Input fields of first record: murali calls "aham" .
my first field is 'murali' and second field is 'calls "aham"'. So when my sort card is something like this...
OUTREC=(1:C'"',
2:1,6
8:C'"',
9:C',',
10:C'"',
11:8,12
23:c'"')
When the Output is sent to lotus notes as .CSV It identies aham a seperate field. Please advice
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
It's not clear what your input records look like, how the fields are delimited, or what you want the output records to look like.
Quote:
e.g Input fields of first record: murali calls "aham" .
my first field is 'murali' and second field is 'calls "aham"'
I don't see a comma delimiter here. I see three "words" here, each delimited by a space:
murali
calls
"aham"
but you say the first field is murali and the second field is calls "aham". What is the rule that tells you the first word is one field, and the second and third words are one field?
Please show a better example of what your input records can look like (more records, all significant variations) and what you'd expect for output. And explain the rules for parsing out the fields from the input record.
Also, what is the RECFM and LRECL of the input file and output file?
Sorry for the inconvenience.. I have shown sample input records. The fields are of fixed width. Also the sort card currently used is shown in the attached document. My problem is when I send the CSV file using IEBGENER to Lotus Notes the double quotes present in the record creates confusion.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Well, you didn't explain this very well. It appears you have fixed fields that you're trying to format as CSV fields for Lotus Notes. Your job would create CSV fields like this:
Code:
"MURALI","CALLS "AHAM"","NO:7,WEST STREET ","ADELAIDE "
"RAM ","CALLS "RAM" ","NO:1,FIRST LANE ","RIO D' JANERIO "
"LAKAN ","ALIAS NONE ","NO ADDRESS ","CITY "NONE" "
But Lotus Notes doesn't handle the CSV file in that form the way you want it to because of the quotes within quotes. So the real question is how the field SHOULD be formatted so that Lotus Notes will treat each comma separated value as a separate field, e.g. CALLS "AHAM" must be treated as one field.
I don't know what Lotus Notes can handle. Would using apostrophes around the fields rather than quotes work? (You could try that - see below.)
Anyone know?
BTW, I'd suggest simplifying your control statements as follows:
Thanks you for the reply frank!!! The simplified code that you have showed here looks crystal clear and easy to understand. BTW the problem in using the apostrophie is that the field values may have them too.. As shown in the example 2 of my input record - Rio d' janerio my input record will contain apostrophes also Not only that they contain semicolon (;) colon( comma(,) slash(/) hash(#) and all the possible symbols. I learnt that when the quotes is doubled it is accepted in output in CSV file. For example
Code:
"MURALI","CALLS ""AHAM""","NO:7,WEST STREET ","ADELAIDE
Now CALLS "AHAM" will be treated as a single field in the CSV file. Now my question is do we have utility that will insert character ? That is If I use IFTHEN=WHEN... OVERLAY it will simply overlay the character with the given character. Can we add extra character using IFTHEN=WHEN?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
It's not as simple as "adding an extra character". What you really need to do is find each quote anywhere in a field and replace it with two quotes. . DFSORT does not have that kind of find and replace function.
We might be able to do something with DFSORT's PARSE function. But it depends on what can be in each field. If the fields of interest can only have string and "string" in various combinations, e.g.
then I think we could work with that. But you'd have to tell me which of the four input fields can have "string" in them and the maximum number of words each such field could have.
Just to repeat myself, try using TAB x'05' instead of the comma and don't use any delimiter.
When I used tab there is no improvement when exported to spreadsheet. Also the tab is not recognised as a delimiter for CSV files in spreadsheet.
You have any idea what are the delimiters recognised for CSV files in a spreadsheet?