How to load a comma seprated text file which contain address in to sql server table using ssis package
Hi,
I want to load a file which is comma separated and contain address .Problem is that address its self comma seprated so how do I differenciate whether comma used for column seprator or it used in address.
for eg.
One person having address like
"c/o AB corp,156 cross lane,USA"
Thanks.....
Hi SR_MCTS,
Based on your description, you want to distinguish a comma is used for column separator or used in address column in a text file, then load the data from the text file to SQL Server table.
As per my understanding, if you can replace the comma column separator to another delimiter like semicolon (;), just do it. Then we can select Semicolon {;} as Column delimiter for the Flat File Connection Manager. Or ensure all columns are enclosed in double
quotes ("). Then we can set the double quotes (") as Text qualifier for the Flat File Connection Manager, and the commas will be loaded as part of the string fields.
If you can't have that done, because computers don't know the context of the data, you would have to come up with some kind of rules that decides when a comma represents a delimiter, and when it is just part of the text. I think a custom script component
would be necessary to pre-process the data, identify where a comma is part of an address, and then treat that as one field.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Similar Messages
-
How to load data from a flat file which is there in the application server
HI All,
how to load data from a flat file which is there in the application server..Hi,
Firstly you will need to place the file(s) in the AL11 path. Then in your infopackage in "Extraction" tab you need to select "Application Server" option. Then you need to specify the path as well as the exact file you want to load by using the browsing button.
If your file name keeps changing on a daily basis i.e. name_ddmmyyyy.csv, then in the Extraction tab you have the option to write an ABAP routine that generates the file name. Here you will need to append sy-datum to "name" and then append ".csv" to generate complete filename.
Please let me know if this is helpful or if you need any more inputs.
Thanks & Regards,
Nishant Tatkar. -
How to select data from 3rd row of Excel to insert into Sql server table using ssis
Hi,
Iam having Excel files with headers in first two rows , i want two skip that two rows and select data from 3rd row to insert into Sql Server table using ssis.3rd row is having column names.CUSTOMER DETAILS
REGION
COL1 COL2 COL3 COL4 COL5 COL6 COL7
COL8 COL9 COL10 COL11
1 XXX yyyy zzzz
2 XXX yyyy zzzzz
3 XXX yyyy zzzzz
4 XXX yyyy zzzzz
First two rows having cells merged and with headings in excel , i want two skip the first two rows and select the data from 3rd row and insert into sql server using ssis
Set range within Excel command as per below
See
http://www.joellipman.com/articles/microsoft/sql-server/ssis/646-ssis-skip-rows-in-excel-source-file.html
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
So we have an Invoice .xlsx File from a 3rd party vendor. It contains two worksheets..."Enrolled" and "Engaged". The data and data columns in each worksheet is different. Is it possible to loop through multiple .xlsx files using SSIS
and a Foreach Loop Container for each spreadsheet, and then another Foreach Loop Container to control each worksheet, and pump the Excel data into a SQL Server Table first for "Enrolled" and then for "Engaged"? How can I control the Foreach
Loop Container in SSIS to process ONLY the "Enrolled" worksheet first? And then the "Engaged" worksheet next?
I know I have multiples out here and I apologize for that...but right now it seems as though I take three steps forward and then two back.
Any help would be GREATLY appreciated!
Thanks in advance!If the structure of the Excel sheets does not change from file to file then you can by having one ForEach Loop processing always the "Enrolled" sheet and another always the "Engaged" this is doable because the Excel OLEDB connector allows
to pick individual sheets, it is problematic therefore when sheet names themselves change.
MSDN has an example: https://msdn.microsoft.com/en-ca/library/ms345182.aspx
Arthur
MyBlog
Twitter -
I know I've REALLY struggled with this before. I just don't understand why this has to be soooooo difficult.
I can very easily do a straight Data Pump of a .xlsX File into a SQL Server Table using a normal Excel Connection and a normal Excel Source...simply converting Unicode to DT_STR and then using an OLE DB Destination of the SQL Server Table.
If I want to make the SSIS Package a little more flexible by allowing multiple .xlsX spreadsheets to be pumped in by using a Foreach Loop Container, the whole SSIS Package seems to go to hell in a hand basket. I simply do the following...
Put the Data Flow Task within the Foreach Loop Container
Add the Variable Mapping Variable User::FilePath that I defined as a Variable and a string within the FOreach Loop Container
I change the Excel Connection and its Expression to be ExcelFilePath ==> @[User::FilePath]
I then try and change the Excel Source and its Data Access Mode to Table Name or view name variable and provide the Variable Name User::FilePath
And that's when I run into trouble...
Exception from HRESULT: 0xC02020E8
Error at Data Flow Task [Excel Source [56]]:SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occured. Error code: 0x80004005.
Error at Data Flow Task [Excel Source [56]]: Opening a rowset for "...(the EXACT Path and .xlsx File Name)...". Check that the object exists in the database. (And I know it's there!!!)
I don't understand by adding a Foreach Loop Container to try and make this as efficient as possible has caused such an error unless I'm overlooking something. I have even tried delaying my validations and that doesn't seem to help.
I have looked hard in Google and even YouTube to try and find a solution for this but for the life of me I cannot seem to find anything on pumping a .xlsX file into SQL Server using a Foreach Loop Container.
Can ANYONE please help me out here? I'm at the end of my rope trying to get this to work. I think the last time I was in this quandry, trying to pump a .xlsX File into a SQL Server Table using a Foreach Loop Container in SSIS, I actually wrote a C# Script
to write the contents of the .xlsX File into a .csv File and then Actually used the .csv File to pump the data into a SQL Server Table.
Thanks for your review and am hoping and praying for a reply and solution.Hi ITBobbyP,
If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
If in this scenario, please refer to the following tips:
The Foreach Loop container should be configured as shown below:
Enumerator: Foreach ADO.NET Schema Rowset Enumerator
Connection String: The OLE DB Connection String for the excel file.
Schema: Tables.
In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
The connection string for Excel Connection Manager is the original one, we needn’t make any change.
Change Table Name or View name to the variable Sheet_Name.
If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to read a line from a file which contains 45000 characters?
Hi all,
Iam a receiving a .CSV file which contains n number of rows ,each row has a data seperated with delimiter.
These values based on delimiter it is seperated and certain validations are handled.
Iam using UTL_FILE.GET_LINE operator to read the value and store it in a variable which is declared as l_text VARCHAR2(30000).
when we receive a line which contains huge characters say 45000 then it throws an error(Unable to read the file).
Only on rare cases we used to receive these kind of files with huge size.
Kindly help to solve this issues.
Database details.
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Hereby i have tried with long Raw data type but still same error unable to read the file.pls find the sample code below,
declare
l_text LONG RAW;
l_importTypeFile UTL_FILE.FILE_TYPE ;
begin
PKG_COMMON.PROC_FOPEN(g_Directory, P_FILENAME, 'RB',l_importTypeFile, p_error_cd, p_error_msg) ;
UTL_FILE.GET_RAW(l_ImportTypeFile,l_Text);
End;
Thanks in Advance
SivaHi Siva,
Are you trying to use data from this .csv file into your realtion tables. If yes and If you are using 11g Oracle database. I would suggest you create External Tables using the below query,
http://www.oracle.com/technetwork/issue-archive/2011/11-mar/o21nanda-312277.html
STEP1: You need a Directory where your SCHEMA has read/write access. Store the csv file in that directory.
STEP2: Create an EXTERNAL Table script. Please refer the above URL. Examples are for coma delimiter (,); replace it with your pipe (|) in the code
STEP: Once your external table is created you can simply create a relational table as below:
CREATE TABLE relation_table
AS
SELECT * FROM external_table;
Regards,
RaviR -
Hi,
I am trying to extract data from multiple CSV files to SQL into a single table. The data type of all the columns in SQL table is nvarchar(MAX). I am able to extract the data from the flat files but some of the data(on extraction) is
corrupt including question marks(?) and other invalid special characters. Also I tried selecting the UTF-8, 65001(Unicode) format but the problem still persists. Also I tried using data converter but no use.
I checked with the data in the flat file but there is no data with question mark(?) or any other special characters.
The separator in the flat file is Comma(,)
Please help.
Thanks in advace.The source system and application determines the code page and encoding. Is it Windows, Unix, Mainframe or some other type?
Unicode files sometimes begin with a byte order mark (2 bytes) to indicate little or big endian. If you open the file in notepad and then select save as, the encoding in the dialog will show the encoding notepad detected based on the BOM. If
that is ANSI instead of Unicode or UTF-8, you will need to know the code page the source system used when the file was created.
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
How to load data in plain-text file into database by using EJB?
Hi,
We need to develop an on-line application which requires us to load input data
from a selected plain-text file on the Web server (iplanet server) into the backend
oracle database. How could I use EJB to make it happen? it seems like using Entity
EJB is not feasible.
Really appreciate your help!
CoronaHi Corona,
"Corona Fang" <[email protected]> wrote in message
news:3f3b0ea3$[email protected]..
We need to develop an on-line application which requires us to load inputdata
from a selected plain-text file on the Web server (iplanet server) intothe backend
oracle database. How could I use EJB to make it happen? it seems likeusing Entity
EJB is not feasible.If you are talking about loading thousands of records,
the preferable way is using plain JDBC calls utilizing
batch methods.
Regards,
Slava Imeshev -
How to load content of my text file into a Vector?
Hi!
Two questions.
Let say I have used BufferedReader(new FileReader(c:/java/MyText.txt)) to read from MyText.txt file. I want to know how to load content of this file (every line describe each photo in my photo-set) into a Vector? And how to associate lines of MyText.txt as an elements of the Vector?
I am trying to do something, but no results.
try{
BufferedReader reader = new BufferedReader(new FileReader("c:/java/Applications/MyText.txt"));
String str=reader.readLine();
JList myList = new JList();
StringTokenizer st = new StringTokenizer(str,"\n");
Vector vr = new Vector(25);
while(st.hasMoreTokens()){
String nextToken = st.nextToken();
vr.addElement(nextToken);
myList.setListData(vr);
TA1.setText(TA1.getText()+
(String)myList.getSelectedValue());
}catch(IOException evt) {};BufferedReader reader = new BufferedReader(new FileReader("c:/java/Applications/MyText.txt"));
Vector photos = new Vector(0,0);
while(reader.ready())
photos.addElement(reader.readLine());
}good luck,
Felipe -
I have a table in sql with employee_num and I need to create a list and link that list to this table to make changes to table based on values user enter or selects.
Hi,
In addition, you could refer to one similar thread for related information:
http://social.technet.microsoft.com/Forums/sharepoint/en-US/8ee8a7b2-ddfc-4654-b84e-b062aeb527ae/how-to-create-exernal-list-in-sharepoint-which-fetch-data-from-multiple-sql-table?forum=sharepointgeneral
Regards,
Rebecca Tu
TechNet Community Support -
Hi All,
I have a simple SSIS package that reads a flat file and copies it into a SQL Server table.
When the flat fiel is on the C drive I have no problem runnign this package from SQL Server Agent, but as soon as I update the path to a network location the package only works when I run it manually, but fails when is executed via the SQL Server agent job.
The error says "cannot open the datafile", while the datafile location is valid.
Is this a kind of limitation of a SQL Server Agent that only local files are allowed to be processed?
Thanks,
Andrei
SSIS questionHi All,
Thanks for your responses.
I configured the SQL agent service to use my domain account with which I have no porblems accessing the folder. However the issue persisted.
Thanks,
Andrei
SSIS question -
Download files from Shared Point document library using SSIS packages
Dear All,
Can you please help me on how can I download excel/CSV files from share point document library to local machine using SSIS packages.
Regads,
Praveen C
Regards, PraveenHi Praveen,
You can also implement
custom component or try third party custom component such as SharePoint List Adapters:
https://sqlsrvintegrationsrv.codeplex.com/releases/view/17652
Regards,
Mike Yin
TechNet Community Support -
How to load the data from excel file into temprory table in Forms 11g?
Hi
How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
Kindly Suggest the Solution.
Regards,
SachinDeclare
v_full_filename varchar2(500);
v_server_path varchar2(2000);
v_separator VARCHAR2(1);
v_filename VARCHAR2(400);
filename VARCHAR2 (100);
v_stop_load varchar2 (2000);
v_rec_error_log varchar2(4000);
v_error_log varchar2(4000);
ctr NUMBER (12);
cols NUMBER (2);
btn number;
RES BOOLEAN;
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
cellType ole2.OBJ_TYPE;
args ole2.obj_type;
PROCEDURE olearg
IS
args ole2.obj_type;
BEGIN
args := ole2.create_arglist;
ole2.add_arg (args, ctr);
ole2.add_arg (args, cols);
cell := ole2.get_obj_property (worksheet, 'Cells', args);
ole2.destroy_arglist (args);
END;
BEGIN
v_full_filename := client_get_file_name(directory_name => null
,file_name => null
,file_filter => 'Excel files (*.xls)|*.xls|'
||'Excel files (*.xlsx)|*.xlsx|'
,message => 'Choose Excel file'
,dialog_type => null
,select_file => null
If v_full_filename is not null Then
v_separator := WEBUTIL_CLIENTINFO.Get_file_Separator ;
v_filename := v_separator||v_full_filename ;
:LOAD_FILE_NAME := substr(v_filename,instr(v_filename,v_separator,-1) + 1);
RES := Webutil_File_Transfer.Client_To_AS(v_full_filename,"server_path"||substr(v_filename,instr(v_filename,v_separator,-1) + 1));
--Begin load data from EXCEL
BEGIN
filename := v_server_path||substr(v_filename,instr(v_filename,v_separator,-1) + 1); -- to pick the file
application := ole2.create_obj ('Excel.Application');
ole2.set_property (application, 'Visible', 'false');
workbooks := ole2.get_obj_property (application, 'Workbooks');
args := ole2.create_arglist;
ole2.add_arg (args, filename); -- file path and name
workbook := ole2.get_obj_property(workbooks,'Open',args);
ole2.destroy_arglist (args);
args := ole2.create_arglist;
ole2.add_arg (args, 'Sheet1');
worksheet := ole2.get_obj_property (workbook, 'Worksheets', args);
ole2.destroy_arglist (args);
ctr := 2; --row number
cols := 1; -- column number
go_block('xxx');
FIRST_RECORD;
LOOP
--Column 1 VALUE --------------------------------------------------------------------
olearg;
v_stop_load := ole2.get_char_property (cell, 'Text'); --cell value of the argument
:item1 := v_stop_load;
cols := cols + 1;
--Column 2 VALUE --------------------------------------------------------------------
olearg;
:item2 := ole2.get_char_property (cell, 'Text'); --cell value of the argument
cols := cols + 1;
--<and so on>
ole2.invoke (application, 'Quit');
ole2.RELEASE_OBJ (cell);
ole2.RELEASE_OBJ (worksheet);
ole2.RELEASE_OBJ (worksheets);
ole2.RELEASE_OBJ (workbook);
ole2.RELEASE_OBJ (workbooks);
ole2.RELEASE_OBJ (application);
END;
--End load data from EXCELPlease mark it as answered if you helped. -
How can u insert and retrieve text files in any format using forms6i.
how can u insert and retrieve text files in any format using forms6i.
can u give me an example of an insert statement, let's assume the file is located in the a:drive.
and retrieving the files, i would give the user a list of all the files that are in the database, the user would select one, but what command(or piece of code) would open the file in its apppropriate editor.
e.g .pdf formatted file would open in acrobat.
any help would be appreciated.
Thanks
Hussein Saigerthe filereference class is for downloading and uploading files.
if you want to load xml, use the xml class.
and, if you want to write to an xml file and don't want to use server-side code, wait. -
Upload Comma separated Text file.
Hi all ,
i would like to upload a comma seperated text file into an internal table using CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD but am not able to load correctly. Please let me know any aditional parameters should be pass to this FM.
data **********
060000012,1001,01052005,2.5,C123,0198345678912
08000001,1001,01052005,5.0,C123,016545678912
08000001,1002,02052005,2.5,C234,012345678912
types : Begin of ty_itab,
pernr(10),
ABS_ATT_TYPE(4),
REC_CCTR(10),
work_order(12),
date(8),
hours(8).
types: end of ty_itab.
data : itab type standard table of ty_itab with header line .
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = 'C:\LOAD.TXT'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
DAT_MODE = SPACE
CODEPAGE = SPACE
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
READ_BY_LINE = 'X'
IMPORTING
FILELENGTH =
HEADER =
CHANGING
DATA_TAB = itab[]
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
NOT_SUPPORTED_BY_GUI = 17
ERROR_NO_GUI = 18
others = 19
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thx
Palanias you are telling that is comma delimited then save the file as comma delimited,
this can be done uisng excel , open the text fiel with excel and save it as .csv file. and try ...
or else i will tell another solution for it...
Data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
Data: begin of itab2 occurs 0,
matnr type mara-matnr
werks type marc-werks
quant(10) type c.
end of itab2.
file = 'C:test.txt'.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = file
filetype = 'ASC'
has_field_separator = 'X'
changing
data_tab = itab
exceptions
others = 17
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Loop at itab.
clear itab2.
split itab-rec at ',' into itab2-matnr
itab2-werks
itab2-quant.
append itab2.
endloop.
you can do using any of the one...
Maybe you are looking for
-
How to create Transport request in R/3(ECC6)
Hi all, Can somebody tell me how to create the transport request in ECC6.0 Regards Kiran Kumar
-
Am I correct that you can no longer place a hard drive in the Dock without it becoming a Stack? I became very used to clicking on a hard drive in the dock and having a Finder window pop up. I suppose I can go back to having the drives show on the Des
-
Google API font not working in all places
Hi guys, I'm working on a site and on one of my pages, google's api font will only work on one header (I have them as a paragraphs) in safari. I've only checked firefox and they look fine there. I'm unable to find a fix or a discussion about this iss
-
How to maintain space between table and header in ssrs
Hi Everyone, I have created a report. In page header of this report, On First Page space between header and body is good , but from next page, space is not maintain. Please suggest me how to maintain space at every page of report. Thanks.
-
Can't use the spacebar in input text??
I've been posting a few things about input and dynamic text in Flash on here I know, but this one has just got me stumped. Do input text fields not recognize the spacebar? I was typing in my input text field in my movie, and noticed I couldn't add sp