473,412 Members | 2,088 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,412 software developers and data experts.

Need to Import xls file into SQL?

The problem is there are duplicate rows in the xls. Who can I test the
database against the xls for duplicates

--
David
Nov 18 '05 #1
3 1277
Clean the data first by loading the data into an arraylist and removing
duplicates. Someone else posted this code in another group - but it should
do the job nicely.

public static ArrayList RemoveDuplicates(ArrayList list) {
ArrayList ret=new ArrayList();
foreach (object obj in list) {
if (!ret.Contains(obj)) ret.Add(obj);
}
return ret;
}

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"DaveF" <df*****@geodecisions.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
The problem is there are duplicate rows in the xls. Who can I test the
database against the xls for duplicates

--
David

Nov 18 '05 #2
The typical approach is to either filter out the messy data with some
custom code that does the import, or create a staging area. A staging
area is a table or set of tables where you can upload the data and
then cleanse it. Remove duplicates, trim strings, etc. A staging area
would not have the same referential integrity constraints as the
production area, so it will allow duplicates and give you a place to
clean the data up.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 22 Nov 2004 15:06:23 -0500, "DaveF" <df*****@geodecisions.com>
wrote:
The problem is there are duplicate rows in the xls. Who can I test the
database against the xls for duplicates


Nov 18 '05 #3
"DaveF" <df*****@geodecisions.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
The problem is there are duplicate rows in the xls. Who can I test the
database against the xls for duplicates


Hi Dave,

First off; this question is probably better suited for either an Excel or
SQLServer newsgroup. You should try there in the future.

But, I just did this Friday, so :

1. Open your xls in Excel and save it to CSV.

2. Import your CSV file into a new table. Don't import directly from an xls
to avoid this problem ... http://www.sqldts.com/default.aspx?6,222,254,0,1

3. Code your insert statement to use the DISTINCT keyword.

Good luck.

Regards,
John MacIntyre
http://www.johnmacintyre.ca
Specializing in; Database, Web-Applications, and Windows Software


Nov 18 '05 #4

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

Similar topics

10
by: Jeff Wagner | last post by:
I am in the process of learning Python (obsessively so). I've been through a few tutorials and read a Python book that was lent to me. I am now trying to put what I've learned to use by rewriting...
0
by: F. GEIGER | last post by:
Hi all, I use Leo for programming. Among other goodies Leo provides it let's me easily share code between different Python apps. When I have an app consisting of more than one file, they usually...
1
by: ADE | last post by:
Hi everyone well from my last post I found what I am looking for I have some code now that transfers files I have added a GUI to it and need some help with two things one my loadtemplate()...
4
by: Active8 | last post by:
I did this once and can't remember how <blush> so I read the reportlab user guid. It says to unzip the reportlab archive - this is on w2k, BTW, with Python23 - to a directory and make a file...
16
by: didier.doussaud | last post by:
I have a stange side effect in my project : in my project I need to write "gobal" to use global symbol : .... import math .... def f() : global math # necessary ?????? else next line...
14
by: mistral | last post by:
Need compile python code, source is in html and starts with parameters: #!/bin/sh - "exec" "python" "-O" "$0" "$@" I have installed ActivePython for windows.
4
by: Hiten | last post by:
Hello all. I have been successful in making a chat program, without streaming the data. However, now that I have replaced the program with input and output streams, I keep getting a...
4
by: krishnakant Mane | last post by:
hello, I am a bit confused. I want to make a program that will take some data from a database and make a string of text. and send it to the respective email id of a person. next I also want to...
4
by: AshishMishra16 | last post by:
HI friends, I am using the Flex to upload files to server. I m getting all the details about the file, but I m not able to upload it to Server. Here is the code i m using for both flex & for...
2
by: sriniwas | last post by:
Hi Frnd's, m using prefuse visulation,it's have one display class and this class have one saveImage(outPutStream, String jpg,double size);. now graph is converting ia jpg image properly.now my...
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...
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
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...

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.