- 浏览: 169250 次
- 性别:
- 来自: 成都
文章分类
source:http://wiki.sdn.sap.com/wiki/display/Snippets/Upload+a+Comma+Delimited+CSV+file+that+contains+commas+in+data
Some Comma Delimited CSV files will contain commas in the data fields and this causes problems in loading the file into our system. I don't think there is a standard function module to do this but I will share a small code snippet which will save someone to re-invent the wheel.
Here is a sample of the comma delimited CSV text file, you can copy below text then paste in notepad and save as c:\Temp\Book1.csv file.
10,Shafiq,"Sacramento, CA"
11,Willie,"New York, NY"
12,Conner,"Seattle, WA"
Here is the sample program which will read this file and store in a table that will preserve the commas in the city field:
Upload from Local PC:
Upload from Unix Server
Some Comma Delimited CSV files will contain commas in the data fields and this causes problems in loading the file into our system. I don't think there is a standard function module to do this but I will share a small code snippet which will save someone to re-invent the wheel.
Here is a sample of the comma delimited CSV text file, you can copy below text then paste in notepad and save as c:\Temp\Book1.csv file.
10,Shafiq,"Sacramento, CA"
11,Willie,"New York, NY"
12,Conner,"Seattle, WA"
Here is the sample program which will read this file and store in a table that will preserve the commas in the city field:
Upload from Local PC:
TYPES: BEGIN OF kcde_intern_struc. INCLUDE STRUCTURE kcde_cells. TYPES: END OF kcde_intern_struc. DATA: l_intern TYPE TABLE OF kcde_intern_struc WITH HEADER LINE. DATA: BEGIN OF it_output OCCURS 0, id(10) TYPE c, name(20) TYPE c, location(20) TYPE c, END OF it_output. DATA: wa_output LIKE LINE OF it_output. DATA: v_index TYPE i. FIELD-SYMBOLS : <fs>. CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT' EXPORTING i_filename = 'C:\Temp\Book1.csv' i_separator = ',' TABLES e_intern = l_intern EXCEPTIONS upload_csv = 1 upload_filetype = 2. LOOP AT l_intern. MOVE : l_intern-col TO v_index. ASSIGN COMPONENT v_index OF STRUCTURE wa_output TO <fs>. MOVE : l_intern-value TO <fs>. AT END OF row. APPEND wa_output TO it_output. CLEAR wa_output. ENDAT. ENDLOOP.
Upload from Unix Server
DATA: BEGIN OF itab_upload OCCURS 0, str(4096), END OF itab_upload. DATA: l_intern TYPE TABLE OF kcde_intern_struc WITH HEADER LINE. OPEN DATASET p_path FOR INPUT ENCODING UTF-8 IN TEXT MODE. DO. READ DATASET p_path INTO itab_upload. IF sy-subrc NE 0. EXIT. ENDIF. APPEND itab_upload. ENDDO. CLOSE DATASET p_path. PERFORM separated_to_intern_convert IN PROGRAM saplkcde TABLES itab_upload l_intern USING ','. LOOP AT l_intern. MOVE : l_intern-col TO v_index. ASSIGN COMPONENT v_index OF STRUCTURE wa_output TO <fs>. MOVE : l_intern-value TO <fs>. AT END OF row. APPEND wa_output TO it_output. CLEAR wa_output. ENDAT. ENDLOOP.
发表评论
-
DISABLE button(FCODE) from the GUI-Status
2014-08-04 15:54 5741. Goto-> Attributes->Pus ... -
Handy SAP function module to automate user events
2013-11-28 09:49 696*Begin-Auto triggers ENTER comm ... -
set Billing block to blank for Sals Order
2013-04-17 15:16 744FM: SD_WF_ORDER_DEL_BILLING_BLO ... -
set Billing block to blank for Sals Order
2013-04-17 15:16 714FM: SD_WF_ORDER_DEL_BILLING_BLO ... -
Unpermitted combination of business object BUS2032 and sales doc. category H
2013-01-25 14:20 4049Q: create New Sales Order using ... -
Function Module: get all users who have specific role
2013-01-25 14:16 588CALL FUNCTION 'RSRA_USERS_O ... -
Create a SELECT-OPTIONS in a module pool screen
2012-03-07 15:35 987source:http://abap-explorer.blo ... -
Converting OTF data from script to Spool Request
2012-03-06 17:25 0source:http://forums.sdn.sap.co ... -
Calculate the days, months and years between 2 dates.
2012-02-21 16:14 794FORM compute_2date_diff. DAT ... -
Retrieving Domain fixed values
2012-02-16 11:13 783source:http://www.saptechnical. ... -
If 1 equals 2, what’s the purpose?
2012-02-16 10:59 794source:http://sapport.blogspot. ... -
get status name for batch input session
2012-01-31 14:47 886Line 601 in program SAPMSBDC_CC ... -
create zip folder with cl_abap_zip
2011-12-05 18:11 1177REPORT ztest. DATA: gv_file ... -
MIRO
2011-11-29 10:39 2030from: http://help-sap.blogspot. ... -
Create Vendor or Customer_master Data
2011-11-23 16:22 2847To Create or Change Vendor_mast ... -
Pay attention to the following points when using append structures
2011-10-27 13:43 1273You cannot create append str ... -
Help Views
2011-10-20 10:46 690source:http://help.sap.com/saph ... -
What is the Different Types and Usage of Views
2011-10-19 23:06 810source:http://www.sap-img.com/a ... -
What is the difference between SET SCREEN and CALL SCREEN ?
2011-09-19 21:50 700source:http://www.saptechies.co ... -
cl_gui_frontend_services=>file_open_dialog
2011-09-09 09:21 1376CALL METHOD cl_gui_frontend_ser ...
相关推荐
通过Kaggle的HR数据集分析身边的小伙伴们为什么要离职,并基于数据集中的特征制定一个评分卡模型来预测会不会离职。 数据集解释 总览:该HR数据集收集了15000份数据,其中3571人离职,离职率23.8%。...
From there, the examples mirror the sqlite3 examples, including creating a database and table, loading data in a CSV input file into a database table, updat‐ ing records in a table using a CSV input...
人力资源分析项目数据集HR_comma_sep.csv
The file classes.txt contains a list of classes corresponding to each label. The files train.csv and test.csv contain all the training samples as comma-sparated values. There are 3 columns in them, ...
comma-separated value (CSV) format as a list of records with commas b‹ items. Having done this, you need only load the file into a text editor o processor; add the dataset’s name using the 4...
用jdbc 连接并读取 csv JDBC driver for CSV ...CsvJdbc is a simple read-only JDBC driver that uses Comma Separated Value (CSV) files as database tables. It is ideal for writing data importing programs.
properly if the folder name contains a comma character. * Version 1.81 o Fixed a crash problem when trying to save outlook attachment. * Version 1.80 o Added 'Add' buttons, which allows you to ...
在做项目的时候,发现使用POI无法解析以csv文件结尾的文件,虽然csv文件能用Excel打开,但是csv文件没有像Excel一样有规定的电子表格形式,故使用POI无法解析csv文件,在网上找了一下,发现java有提供java csv文件来...
covert output matlab file .mat to comma seaparated file csv so one can open in microsoft excel
o Fixed bug in saving as comma-delimited file when field values contained comma character. * Version 1.34: o New Option: Remember Last Filter (The filter is saved in cports_filter.txt) * Version...
Vundle: Plugin 'mechatroner/rainbow_csv' VimPlug: Plug 'mechatroner/rainbow_csv' dein: call dein#add('mechatroner/rainbow_csv') 无需其他步骤-Rainbow CSV可以直接使用。 总览 主要特点: 用不同的...
csv是Comma-Separated Values的缩写,是用文本文件形式储存的表格数据,比如如下的表格 就可以存储为csv文件,文件内容是: No.,Name,Age,Score 1,Apple,12,98 2,Ben,13,97 3,Celia,14,96 4,Dave,15,95 假设上述...
simcdma.m allows a set of CDMA parameters to be simulated, such as BER verse number of users, etc. All the graphs used in ...is a Result.txt file which is a comma delimited spread sheet compatible file.
人力资源数据包含15000行数据信息,可以用于预处理、数据可视化分析以及数据挖掘分析,请勿商业,探讨学习使用
The file classes.txt contains a list of classes corresponding to each label. The files train.csv and test.csv contain all the training samples as comma-sparated values. There are 3 columns in them, ...
simcdma.m allows a set of CDMA parameters to be ...is a Result.txt file which is a comma delimited spread sheet compatible file. simcdma.m also has all the settings for the CDMA link parameters.
CSV全称Comma-Separated Values,它是一种通用的,简单的,被广泛采用的一种表格数据格式。采用纯文本格式存储,用分隔符号分开。它格式类似于数据库表格,每一行,中间用分隔符分开,一行就是一条记录,一列就是一...
unity开发使用的csv简易插件,逗号分隔值(Comma-Separated Values,CSV,有时也称为字符分隔值,因为分隔字符也可以不是逗号),其文件以纯文本形式存储表格数据(数字和文本)。纯文本意味着该文件是一个字符序列...
For convenience, assume that none of the fields have spaces or commas in them, so you can read a comma separated file without worrying about those (non-algorithm related) complications. No need to ...