473,382 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Import large CSV file data into Oracle Table

Language: C#.NET 2.0
Technology: ASP.NET 2.0
Database: Oracle 10g

Hi All,

Could any one of you please suggest the BEST method to:
1. Fetch data from a very large .csv file (around 8 MB) and Inert the same
into Oracle Table using a Bulk Insert.

Any suggestions on the directions to execute the above mentioned task will
be highly appreciated.

Thanks in advance,
Kuldeep

--
None in itself cannot be empty!
Jun 27 '08 #1
3 9367
On Tue, 27 May 2008 01:04:03 -0700, Kuldeep Vijaykumar
<Ku***************@discussions.microsoft.comwrot e:
>Language: C#.NET 2.0
Technology: ASP.NET 2.0
Database: Oracle 10g

Hi All,

Could any one of you please suggest the BEST method to:
1. Fetch data from a very large .csv file (around 8 MB) and Inert the same
into Oracle Table using a Bulk Insert.
I'm not going to do all of your work for you, but the BULK INSERT
statement is merely a Transact-SQL statement can be executed in a
C#.NET program by using either a SQLConnection and a SQLCommand or an
ODBCConnection and ODBCCommand.

The only catch is that you will have to come up with the appropriate
syntax for the BULK INSERT command. You will need to specifiy a few
command options that will describe the format of the input file, in
this case a CSV file.
Jun 27 '08 #2
On May 27, 2:04*am, Kuldeep Vijaykumar
<KuldeepVijayku...@discussions.microsoft.comwrot e:
Language: C#.NET 2.0
Technology: ASP.NET 2.0
Database: Oracle 10g

Hi All,

Could any one of you please suggest the BEST method to:
1. Fetch data from a very large .csv file (around 8 MB) and Inert the same
into Oracle Table using a Bulk Insert.

Any suggestions on the directions to execute the above mentioned task will
be highly appreciated.

Thanks in advance,
Kuldeep

--
None in itself cannot be empty!
Hello:

I handled this exact situation. I will list here exactly what I did.
You can just take what you want from it.

1) I created a IDataReader base class specifically for reading
the .CVS. I would recommend that you skip this step and just pull the
data directly from the file and convert the data to the appropriate
type. I would also recommend BufferedStream class to minimize hits to
the hard drive. If it will fit, I would also recommend trying to get
the entire file into memory prior (depending on your situation).

2) Use OracleCommand (I assume you're using Oracle). Instead of
passing a value to a parameter, pass an array of values. Set the
ArrayBindSize to the size of the array. I would recommend tweeking
with the max array size to see what performs the best. In my
situation, there was an obvious grouping among data; so I made my
array size the size of groups.

If you need to make the parameters array dynamic, create a List<type>
for each parameter. Add to the lists until you are ready to dump to
the database. Then convert the List<type>s to arrays using the
ToArray() method.

Send me an email if you need a more detailed example. Furthermore, I
have a small BulkInserter class I wrote a many ages ago to make this a
little more simple. Here it is:

public class BulkInserter
{
private readonly Dictionary<string, List<object>values
= new Dictionary<string, List<object>>();

public void AddValue(string parameterName, object value)
{
List<objectparamValues;
if (!values.TryGetValue(parameterName, out paramValues))
{
values[parameterName] = paramValues = new
List<object>();
}
paramValues.Add(value);
}

public int ExecuteNonQuery(OracleCommand command)
{
int paramArrayCount = 0;
foreach (KeyValuePair<string, List<object>paramData in
values)
{
paramArrayCount = Math.Max(paramArrayCount,
paramData.Value.Count);
command.Parameters[paramData.Key].Value =
paramData.Value.ToArray();
}
command.ArrayBindCount = paramArrayCount;
return command.ExecuteNonQuery();
}
}
Jun 27 '08 #3
Joe Cool wrote:
On Tue, 27 May 2008 01:04:03 -0700, Kuldeep Vijaykumar
<Ku***************@discussions.microsoft.comwrot e:
>Language: C#.NET 2.0
Technology: ASP.NET 2.0
Database: Oracle 10g
>Could any one of you please suggest the BEST method to:
1. Fetch data from a very large .csv file (around 8 MB) and Inert the same
into Oracle Table using a Bulk Insert.

I'm not going to do all of your work for you, but the BULK INSERT
statement is merely a Transact-SQL statement can be executed in a
C#.NET program by using either a SQLConnection and a SQLCommand or an
ODBCConnection and ODBCCommand.

The only catch is that you will have to come up with the appropriate
syntax for the BULK INSERT command. You will need to specifiy a few
command options that will describe the format of the input file, in
this case a CSV file.
Possible Oracle 10g <SQLServer ...

Arne
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: M Bouloussa | last post by:
Hello, I have a little problem with an oracle import. My problem is : 1) I have a dump (file.dmp) contains a table T1 (just for this example) 2) I have an oracle schema (user=U1, pass=pass1)...
6
by: Matt Liverance | last post by:
I REALLY dont want to switch to oracle :( but I cant get these tables working any faster. I've got 2 dedicated servers, each with a slave, all run 32gig 15k rpm raid 5 on u320 perc raid...
3
by: Jon Ole Hedne | last post by:
My Access 2002-application need to work with tables from both Oracle and Access. To solve this, I want to run some querys on three views in Oracle and import the results into temporary...
1
by: Arti Potnis | last post by:
Hi, I want to import some tables from Oracle 9i to MS Access 2000. I'm able to import the table structures and data using File->Get External Data->Import . (I don't want to import links)...
3
by: ninrulz | last post by:
I will try to explain my situation. I know that it is hard to offers solutions without fully understanding what people would like to achieve. I receive 2 csv files every month. The csv files...
7
by: Randy | last post by:
Folks: We have a web-based app that's _really_ slowing down because multiple clients are writing their own private data into a single, central database. I guess the previous programmer did...
3
by: jelinjose | last post by:
Hi, I have created a table with table name T1 with a particular schema. I have entered the data in an excel sheet in the particular schema above and saved as T2.dmp file. I would like to know...
0
by: jen78 | last post by:
Hi, I am new to Oracle administration and hope someone can help me out on this as i am struggling to make it work.... I am doing development work using oracle database on my own development...
14
by: mfrsousa | last post by:
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.