Comma Seperated Value Issue

Hello,

I have a problem in reading the CSV file in our program.
Examle:
CSV row1 : 117021, 562012, Oilcompany Ltd, 1229802
CSV row2: 117021, 562076, L&C Brother Holdings, Inc, 1229541


Table Field 1 Field 2 Field 3 Field 4 Field 5
CSV row1 117021 562012 Oilcompany Ltd 1229802
CSV row2 117021 562076 L&C Brother Holdings Inc 1229541

The row 1 was looks good and reading the records as expected. The row 2 vendor name string as L&C Brother Holdings, Inc, this is spliting because the string having the comma inside, this is wrong.
Could someone pls tell me how to read L&C Brother Holdings, Inc as one string not two.
 

BOster

Legendary Poster
The CSV file is malformed. A properly formatted CSV file doesn't have any issues with delimiters or text qualifiers in the actual data. Unfortunately, unless you can "fix" what is outputting the data to do it correctly you are going to have issues. You need text qualifiers around text fields and any text qualifiers in the actual data need to be properly escaped.

Code:
117021, 562076, L&C Brother Holdings, Inc, 1229541

S/B

Code:
117021,562076,"L&C Brother Holdings, Inc",1229541

And if the record contains a " character like below:

Code:
117021, 562076, L&C Brother " Holdings, Inc, 1229541

S/B

Code:
117021,562076,"L&C Brother "" Holdings, Inc",1229541


https://en.wikipedia.org/wiki/Comma-separated_values
https://www.ietf.org/rfc/rfc4180.txt
 

Chan Rana

Legendary Poster
You either fix the CSV as mentioned above by Brain or there is other way which might need your code to handle the string. There is feature in EXcel to embede the string in quotes so it would come like "L&C Brother Holdings, Inc" , 1234 etc. You can then handle it in code accordingly.

Hope this helps.

Chan
 

Jay Kumar

Active Member
Hello,

I have a problem in reading the CSV file in our program.
Examle:
CSV row1 : 117021, 562012, Oilcompany Ltd, 1229802
CSV row2: 117021, 562076, L&C Brother Holdings, Inc, 1229541


Table Field 1 Field 2 Field 3 Field 4 Field 5
CSV row1 117021 562012 Oilcompany Ltd 1229802
CSV row2 117021 562076 L&C Brother Holdings Inc 1229541

The row 1 was looks good and reading the records as expected. The row 2 vendor name string as L&C Brother Holdings, Inc, this is spliting because the string having the comma inside, this is wrong.
Could someone pls tell me how to read L&C Brother Holdings, Inc as one string not two.

Hi dhanasekaran,

you can use the business function Replace character in a string (B0400520) to remove (replace) the commas from a string with blank or space. And that will you to read the vendor name in one cell as "L&C Brother Holdings Inc".

Hope this will help!
 

Chan Rana

Legendary Poster
Hi dhanasekaran,

you can use the business function Replace character in a string (B0400520) to remove (replace) the commas from a string with blank or space. And that will you to read the vendor name in one cell as "L&C Brother Holdings Inc".

Hope this will help!

This wont help since he has to read csv first and then read string. It will be read as L&C Brother Holdings and then Inc separately.
 
Top