hi there,
i have a huge large text file (350.000 lines) that i want to import to
a MS Acccess Database, of course i don't want to use Access, but do it
with C#.
i already have tried the AddRow method or Insert, reading each line of
the text file, the problem of course is velocity, it would take more
than 4 hours to add all lines/records to the database.
any suggestion?
than you 14 11263
On 3 Mar 2007 08:36:21 -0800, mfrsousa wrote:
hi there,
i have a huge large text file (350.000 lines) that i want to import to
a MS Acccess Database, of course i don't want to use Access, but do it
with C#.
i already have tried the AddRow method or Insert, reading each line of
the text file, the problem of course is velocity, it would take more
than 4 hours to add all lines/records to the database.
any suggestion?
than you
A bit more info would help ... do you want each line to go into its own
row in the database or all the lines into one field
--
Bits.Bytes http://bytes.thinkersroom.com
"mfrsousa" <mf******@gmail .comwrote in message
news:11******** *************@t 69g2000cwt.goog legroups.com...
i have a huge large text file (350.000 lines) that i want to import to
a MS Acccess Database, of course i don't want to use Access, but do it
with C#.
i already have tried the AddRow method or Insert, reading each line of
the text file, the problem of course is velocity, it would take more
than 4 hours to add all lines/records to the database.
First of all, there is no such thing as an "Access database" per se -
Microsoft Access, like several other Micrsoft applications, uses the Jet
database format...
You say you don't want to use Access - is there any particular reason for
this...? I strongly suggest you open up the database in Access, open the
table in question, then import the text file using the Get External Data
functionality and time how long it takes - I'm willing to bet it will be
nothing like 4 hours...
Obviously if Access isn't installed, then your options are pretty much
limited to ADO.NET and the Jet OleDb provider. However, you might like to
consider using transactions to "batch" the imports into groups of, say
10,000 records - I've achieved massive speed gains with this technique in
the past...
On 3 Mar 2007 08:36:21 -0800, "mfrsousa" <mf******@gmail .comwrote:
>hi there,
i have a huge large text file (350.000 lines) that i want to import to a MS Acccess Database, of course i don't want to use Access, but do it with C#.
i already have tried the AddRow method or Insert, reading each line of the text file, the problem of course is velocity, it would take more than 4 hours to add all lines/records to the database.
any suggestion?
For a bulk load of a database, such as you describe, it is often
better to switch off indexing on the affected tables before starting
the load and then rebuilding the indexes from scratch after the bulk
load has finished.
rossum
rossum wrote:
For a bulk load of a database, such as you describe, it is often
better to switch off indexing on the affected tables before starting
the load and then rebuilding the indexes from scratch after the bulk
load has finished.
rossum
Right i was just reading this bulk thing (sorry my ignorance), the
problem is that i have tried something like this:
/*************** *************** ******** CODE
*************** *************** */
string conn = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=|
DataDirectory|\ \db.mdb";
OleDbConnection oleconn = new OleDbConnection (conn);
oleconn.Open();
string sqlstr = "BULK INSERT INTO tblExtData (ext_disc, ext_num,
ext_track, ext_artist) FROM 'c:\\data1.lst' )";
OleDbCommand olecom = new OleDbCommand(sq lstr, oleconn);
olecom.ExecuteN onQuery();
/*************** *************** ******** CODE
*************** *************** */
and i get this error
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE',
'SELECT', or 'UPDATE'.
i think that the OleDB doesnt support the bulk command
could you point to some bulk reading or explain better please
thanks
Mark Rae wrote:
First of all, there is no such thing as an "Access database" per se -
Microsoft Access, like several other Micrsoft applications, uses the Jet
database format...
You say you don't want to use Access - is there any particular reason for
this...? I strongly suggest you open up the database in Access, open the
table in question, then import the text file using the Get External Data
functionality and time how long it takes - I'm willing to bet it will be
nothing like 4 hours...
Obviously if Access isn't installed, then your options are pretty much
limited to ADO.NET and the Jet OleDb provider. However, you might like to
consider using transactions to "batch" the imports into groups of, say
10,000 records - I've achieved massive speed gains with this technique in
the past...
Yes i'm developing an applicattion so i don't expect that everyone
will have the MAccess installed to make this operation. I will have a
look on the batch imports.
Thanks
On 3 Mar 2007 12:14:57 -0800, "mfrsousa" <mf******@gmail .comwrote:
> rossum wrote:
>For a bulk load of a database, such as you describe, it is often better to switch off indexing on the affected tables before starting the load and then rebuilding the indexes from scratch after the bulk load has finished.
rossum
Right i was just reading this bulk thing (sorry my ignorance), the problem is that i have tried something like this:
/*************** *************** ******** CODE ************** *************** **/ string conn = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=| DataDirectory| \\db.mdb"; OleDbConnectio n oleconn = new OleDbConnection (conn); oleconn.Open() ;
string sqlstr = "BULK INSERT INTO tblExtData (ext_disc, ext_num, ext_track, ext_artist) FROM 'c:\\data1.lst' )"; OleDbCommand olecom = new OleDbCommand(sq lstr, oleconn); olecom.Execute NonQuery();
/*************** *************** ******** CODE ************** *************** **/
and i get this error
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
i think that the OleDB doesnt support the bulk command
could you point to some bulk reading or explain better please
thanks
I do not know MS SQL, all my experience was with Oracle SQL some time
ago.
Basically the sequence is:
Delete all indexes for tables to be loaded
Load data into tables
Rebuild/create indexes for tables just loaded
If you load data into an indexed table then each line inserted into
the table also requires an update to the index(es) for that table. By
dropping all the indexing before a bulk load you do not have the
overhead of re-indexing during the run.
Rebuilding the indexes from scratch is faster than trying to keep them
up to date while loading 350,000 lines into a table.
HTH
rossum
"mfrsousa" <mf******@gmail .comwrote in message
news:11******** **************@ z35g2000cwz.goo glegroups.com.. .
>
rossum wrote:
>For a bulk load of a database, such as you describe, it is often better to switch off indexing on the affected tables before starting the load and then rebuilding the indexes from scratch after the bulk load has finished.
rossum
Right i was just reading this bulk thing (sorry my ignorance), the
problem is that i have tried something like this:
/*************** *************** ******** CODE
*************** *************** */
string conn = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=|
DataDirectory|\ \db.mdb";
OleDbConnection oleconn = new OleDbConnection (conn);
oleconn.Open();
string sqlstr = "BULK INSERT INTO tblExtData (ext_disc, ext_num,
ext_track, ext_artist) FROM 'c:\\data1.lst' )";
OleDbCommand olecom = new OleDbCommand(sq lstr, oleconn);
olecom.ExecuteN onQuery();
/*************** *************** ******** CODE
*************** *************** */
and i get this error
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE',
'SELECT', or 'UPDATE'.
i think that the OleDB doesnt support the bulk command
could you point to some bulk reading or explain better please
thanks
You are correct, I do not believe Access supports BULK Insert. SQLServer
does, but that's not much help to you.
Your choices are to try to figure out how to use OLE Automation to get
Access to import the file, or to write a line-by-line import. (First option
will be much faster). You might try posting your question to
microsoft.publi c.framework.ado net unless there's someone over there who can
help you who doesn't read this forum.
Robin S.
"rossum" <ro******@coldm ail.comwrote in message
news:v9******** *************** *********@4ax.c om...
If you load data into an indexed table then each line inserted into
the table also requires an update to the index(es) for that table. By
dropping all the indexing before a bulk load you do not have the
overhead of re-indexing during the run.
Or perform the writes within a transaction - indexes are only updated when
the transaction is committed...
On Mar 4, 7:48 pm, "RobinS" <Rob...@NoSpam. yah.nonewrote:
>
You are correct, I do not believe Access supports BULK Insert. SQLServer
does, but that's not much help to you.
Your choices are to try to figure out how to use OLE Automation to get
Access to import the file, or to write a line-by-line import. (First option
will be much faster). You might try posting your question to
microsoft.publi c.framework.ado net unless there's someone over there who can
help you who doesn't read this forum.
Robin S.
thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rune Johansen |
last post by:
Hi,
I'm sorry if these questions are trivial, but I've searched the net and
haven't had any luck finding the information I need.
I need to perform some regular expression search and replace on a large
text file. The patterns I need to match are multi-line, so I can't do it
one line at a time. Instead I currently read in the entire text file in
a string using the code below.
|
by: atse |
last post by:
Hi,
I am still stick on the text file being imported to database. Can anybody help?
I have just done the csv format files. And then I work on text and DAT formats, but I have problem to import these kinds of formats to MySQL ( and MS SQL)
Please see the attachments, and the text format is changed from DAT format, delimited by tabs or commas. I can't select and insert them into the database.
When I try:
select * from thisfile.txt and...
|
by: adrian GREEMAN |
last post by:
When I try to import a text file with new data for an existing
table I get the error "1148 - the used command is not allowed
with this MySQL version."
I have tried with both PHPMyAdmin2.3 and with MySQLFront 2.5.
Both these GUI programmes have an "import from text file" command
which I have used successfully several times to add entries to
this table before - running just this MySQL version. I have
structured the data in the text...
|
by: jcrouse |
last post by:
Here is a sniplet from a text file
game
name mapp
description "Mappy (US)
year 198
manufacturer "Namco
history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US manufacture and distribution. (03/1983) \n\n- SERIES: \n\n1. Mappy \n2. Hopping Mappy \n\n0.26 \n\nBugs: \n- \"000\" is displayed on the highscore. If you get more than 30000 pts, it is displayed normally. This happens whether there are...
|
by: bienwell |
last post by:
Hi all,
Do you have any source code to import data from Excel file or text file into
database in ASP.NET program ? Please give me your reference if you have.
Thanks in advance
| |
by: diasdaman |
last post by:
I know how to import text files, but in this case I need to import a text file line by line on an on-the-fly basis, such that the Access will look at the first two digits of a line, and then import the rest of the line based on a given specification into an appropriate table.
I'm not that familiar with VBA, but I can pick it up if I need to. But first I want to know if what I want to do is even possible.
|
by: Edwin.Madari |
last post by:
here is a working code snippet to read from MySQL db.
python tutorial has examples of reading from files.
put them together to do your task.
===================================================
import MySQLdb
con = MySQLdb.connect(host='127.0.0.1',
port=4321, user='joe', passwd='shmoe', db='tst')
cursor = con.cursor()
sql = 'select * from YOUR_TABLE'
|
by: sarthur |
last post by:
Hi Friends,
I am trying to get the last 50 Mb of a large Text file(Over 2 GB) using VB. I have to add this to an Access form so that when the user clicks the button a pop up window asks for the source of the text file and the destination of the output file and then it saves only the last 50 MBytes of the file to the output location. I am not that good in VB programming. I would appreciate if anyone can help me on this?
Thanks,...
|
by: Miguel Valenzue |
last post by:
I collect traffic data from a machine that outputs text files with the data.
I want to import each text file as it's own table into an Access database and do it without having to run the import wizard for each one.
As part of this function, I'd like to strip the first 15 lines of data from the dataset, parse in the first 5 columns, and name the table after the information on line 3 which is the name of the street the data was taken from.
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |