Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CSV file read

Former Member
0 Likes
774

Is there a standard FM which handles csv file read? I am currently using a 'split at' to separate values but this fails when some strings ( within quotes) have commas.

Eg:

333,khdfs, "Company name", 87348, " Name1, Name2"

In this scenerio, the last field in quotes gets split into 2. I cannot handle this in the progrm because the last field does not always have a comma split. Any suggestions?

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
723

I think we don't have any easy way to do this.

My suggestion will be first search the string for starting " and ending " (offset) and then replace the , (in between 2 ") with some other symbol say # something like then go for split.

a®

6 REPLIES 6
Read only

former_member194669
Active Contributor
0 Likes
724

I think we don't have any easy way to do this.

My suggestion will be first search the string for starting " and ending " (offset) and then replace the , (in between 2 ") with some other symbol say # something like then go for split.

a®

Read only

0 Likes
723

thats a good approach, probably the only approach. Do u have any code with u using offsets?

Pinaki, ur suggestion wont work

Read only

0 Likes
723

Rahul - I have same situation. I have a comma separated CSV file which has address fields with embedded commas in them.

Can you tell me exactly how this has been solved.

Many Thanks.

Read only

Former Member
0 Likes
723

Hi Suker ,

First you remove all the Quotes , then split into coma (,).

I mean to say --

REPLACE   ALL   OCCURRENCES OF '"'  IN <string_name> WITH SPACE.

Now split the string at the coma - -

SPLIT  AT  ....

Regards

Pinaki

Read only

Former Member
0 Likes
723

Dear ,

I think you should save your file in excel with csv format and then upload this file with FM "GUI_UPLOAD'.

Regards,

Vijay

Read only

Former Member
0 Likes
723

Hi,

use this FM

TEXT_CONVERT_TEX_TO_SAP

In the parameter i_field_seperator pass ",".

Regards,

Manish