If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Need help for bulk insert

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-19-05, 03:45
SChemnitzer SChemnitzer is offline
Registered User
 
Join Date: Jan 2005
Posts: 3
Need help for bulk insert

My problem is a ASCII-file with fieldterminator=';', rowterminator='\n' and a header-line (Firstrow=2). The SQL-Server didn't find the header-line because in this line are no fieldterminators. How can I import this file looks like:
1. row: ****This is a test-file***
2. row: field1;field2;field3;field4;field5

Thanks
Reply With Quote
  #2 (permalink)  
Old 01-19-05, 04:44
Sreemace Sreemace is offline
Registered User
 
Join Date: Dec 2004
Posts: 47
Do u have DB manager cleint installed in ur machine... it have data management utility thru which u can import data easily.. and what u r saying about the header line, little bit confused is it the table feild names u r mentioning... take it off..... how can an automized thing identify it...
Reply With Quote
  #3 (permalink)  
Old 01-19-05, 04:58
SChemnitzer SChemnitzer is offline
Registered User
 
Join Date: Jan 2005
Posts: 3
OK, any more infos:
I have installed the full sql-server, bat I have to import the file automaticly from my C++ programm. Therefor I have write a saved procedure, in wich the import and any other tasks will done. I can't use any manager for the import. The most problem is, that the sql-server checked first the fieldterminator and then the firstrow-value. But in my case there are no fieldterminators in the first line, wich I will not import.
I hope this informations helps for this problem.
Reply With Quote
  #4 (permalink)  
Old 01-19-05, 08:48
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
Look at LOAD DATA INFILE in the manual. It tells you explicitly how to skip lines from your input file. at the end of your load data infile command add
Code:
IGNORE 1 LINES
Yes lines needs to be plural even though it is only 1 line you are ignoring.
You could ignore as many lines at the beginning of the file that you want to.
Reply With Quote
  #5 (permalink)  
Old 01-19-05, 10:22
SChemnitzer SChemnitzer is offline
Registered User
 
Join Date: Jan 2005
Posts: 3
Thank you for answer, but this is not my problem,

my problem is, that I have to generate the insert-statement in a procedure. I can't use any managers or format files, because I don't know the file structur in design-time. During runtime I create the bulk insert statement with any parameters. In one time there are ";" for fieldterminators, in other times tabs and so on.
My bulk insert statement works fine, but if the first line don't have any fieldterminators, the import isn't correct.
The bulk insert statement havn't any ignore lines parameter, there is only the firstrow parameter.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On