<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Reading CSV file in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015305#M959398</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when creating CSV files make sure that your data doesnt contain any , in them....it gives wrong data while reading as internally it is stored as "data1, data2".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we can overcome this by using this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when creating itself... u concatenate the data into field string separated by comma&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate data1 ',' data2 into string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate data1 ' "," ' data2 into string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this should solve ur problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;padma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Jun 2008 14:41:20 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-27T14:41:20Z</dc:date>
    <item>
      <title>Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015298#M959391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am reading CSV located on PC or unix server and loading into internal table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    LOOP AT itab1 INTO WA_itab1.
      SPLIT WA_itab1 AT ',' INTO WA_INPUT-f1
.....                                           WA_INPUT-f2  
                                                WA_INPUT-f3
                                                WA_INPUT-f4.
append wa_input to it_input.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the above code works fine when f1,f2,f3,f4 are seperated by comma....however when the data in the field is f3 is separated by extra comma then field f4 is filled by wrong data ...how can i avoid it this situation .......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 19:06:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015298#M959391</guid>
      <dc:creator>SG141</dc:creator>
      <dc:date>2008-06-17T19:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015299#M959392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;YOu cannot do anything in such situation.&lt;/P&gt;&lt;P&gt;Having a comma as data in a csv file will cause this issue for ever.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 19:23:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015299#M959392</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-17T19:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015300#M959393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Currently when a single field is split into two by a comma then it is in double " data1, data2" can we identify the way and delete ',' ????&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 19:48:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015300#M959393</guid>
      <dc:creator>SG141</dc:creator>
      <dc:date>2008-06-17T19:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015301#M959394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi if data have a comma... then better go for some other format of file like a pipe '|' or tab delimited file.. that is the only option..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 19:55:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015301#M959394</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2008-06-17T19:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015302#M959395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I made this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
types: begin of this_type,
a(15),
b(15),
c(15),
d(15),
end of this_type.

data: itab type table of string with header line.
data: itab2 type table of this_type with header line.
data: stringa(1024).
data: lenght type p.
field-symbols &amp;lt;fs&amp;gt; type any.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                      = 'C:\Book1.csv'
  tables
    data_tab                      = itab.

loop at itab.
do.
assign component sy-index of structure itab2 to &amp;lt;fs&amp;gt;.
if sy-subrc ne 0.
exit.
endif.
split itab at ',' into &amp;lt;fs&amp;gt; itab.
lenght = strlen( &amp;lt;fs&amp;gt; ).
lenght = lenght - 1.
if &amp;lt;fs&amp;gt;(1) = '"' and lenght ne 0.
if &amp;lt;fs&amp;gt;+lenght ne '"'.
split itab at '"' into stringa itab.
concatenate &amp;lt;fs&amp;gt; ',' stringa '"' into &amp;lt;fs&amp;gt;.
split itab at ',' into stringa itab.
endif.
endif.

enddo.
append itab2.
clear itab2.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with this csv&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
1,"hola,amigos",2,3
"hello,dude",2,"1,2,3,4",3
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It goes to itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I must tell you, it will only work if you don't have double quotes (") in any field.&lt;/P&gt;&lt;P&gt;I would say that you need to use another delimiter or tell the user to not use quotes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 20:17:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015302#M959395</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-17T20:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015303#M959396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Karthik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option you can try is to create the csv file with a double comma&lt;/P&gt;&lt;P&gt;ie: each field separated by ,,&lt;/P&gt;&lt;P&gt;opening it in excel will have a blank row in between, but when reading it, you can modify your code as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    LOOP AT itab1 INTO WA_itab1.
      SPLIT WA_itab1 AT ',,' INTO WA_INPUT-f1
.....                                           WA_INPUT-f2  
                                                WA_INPUT-f3
                                                WA_INPUT-f4.
append wa_input to it_input.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hence if a single comma appears in the data, it will not get split into the next cell&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2008 03:15:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015303#M959396</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2008-06-18T03:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015304#M959397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Karthik,&lt;/P&gt;&lt;P&gt;              Have you got the solution for this problem you have raised . If so could you please let me know the solution sothat i can implement. Iam facing exactly the same situation ........pleae do let meknow  in the .csv&lt;/P&gt;&lt;P&gt;file when you are trying to upload how you have handled&lt;/P&gt;&lt;P&gt;in the scenario where in a particular field  where you have data as below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A              B          c                          D&lt;/P&gt;&lt;P&gt;101         raja        cleark,supervisor    500&lt;/P&gt;&lt;P&gt;102         raju        cleark                    200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here when iam uploading the data has to go  as &lt;/P&gt;&lt;P&gt;cleark,supervisor only .......but since when we are using split at .........this data is getting splitted at two cleark and supervisor  .......which is wrong .......please help m&lt;/P&gt;&lt;P&gt;little urgent .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;madhuri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2008 14:10:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015304#M959397</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-27T14:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015305#M959398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when creating CSV files make sure that your data doesnt contain any , in them....it gives wrong data while reading as internally it is stored as "data1, data2".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we can overcome this by using this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when creating itself... u concatenate the data into field string separated by comma&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate data1 ',' data2 into string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate data1 ' "," ' data2 into string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this should solve ur problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;padma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2008 14:41:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015305#M959398</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-27T14:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015306#M959399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;When my data contains  ' ,' in it's content, it will be encapsulated by " ", &lt;/P&gt;&lt;P&gt;eg it will be like   test1," data1,date2",test3 i wrote below logic and it works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;str1 = test1," data1,date2",test3 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;split str1 at ',", into str1 str2.&lt;/P&gt;&lt;P&gt;(now str1 has test1 and str2 has data1,data2",test3.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;split str2 at '",' into str2 str3.&lt;/P&gt;&lt;P&gt;(now str2 has data1, data2  and str3 has test3.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;replace , with ' ' into str2. ( to get ridff comma)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate str1 str2 str3 into str1 separated by ','.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i used the above logic to get ridsff unwanted commas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Karthik on Jun 27, 2008 10:50 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2008 19:10:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reading-csv-file/m-p/4015306#M959399</guid>
      <dc:creator>SG141</dc:creator>
      <dc:date>2008-06-27T19:10:24Z</dc:date>
    </item>
  </channel>
</rss>

