Click here to Skip to main content
15,891,253 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Sorting numbers then adding to a database Pin
jkirkerx17-Dec-11 21:02
professionaljkirkerx17-Dec-11 21:02 
GeneralRe: Sorting numbers then adding to a database Pin
Chris_B8418-Dec-11 1:25
Chris_B8418-Dec-11 1:25 
GeneralRe: Sorting numbers then adding to a database Pin
Richard MacCutchan18-Dec-11 4:39
mveRichard MacCutchan18-Dec-11 4:39 
GeneralRe: Sorting numbers then adding to a database Pin
Chris_B8418-Dec-11 5:23
Chris_B8418-Dec-11 5:23 
AnswerRe: Sorting numbers then adding to a database Pin
Not Active18-Dec-11 9:03
mentorNot Active18-Dec-11 9:03 
Questionrelated news function? Pin
duongvannam16-Dec-11 17:39
duongvannam16-Dec-11 17:39 
AnswerRe: related news function? Pin
Not Active17-Dec-11 3:54
mentorNot Active17-Dec-11 3:54 
QuestionComparing array of strings Pin
indian14316-Dec-11 6:23
indian14316-Dec-11 6:23 
Hi,

I have an asp.net application which loads data from csv file. I need to check for duplicate rows in the csv file and should not process them and give error message for those duplicate rows.

I did in some approach but got the comments like performance is impacted. Is there any performance oriented process available to compare the string arrays

Any type of help is greatly appreciate.

Here is my code

private static bool CheckForDuplicateRow(FileInfo file
            ,string[] line
            ,int lineNumber
            ,ref bool lineAlreadyVerified)
        {
            CsvStream csvStream;

            using (Stream fileStream = file.OpenRead())
            {
                using (StreamReader reader = new StreamReader(fileStream))
                {
                    csvStream = new CsvStream(reader);
                    string[] rowItems;
                    try
                    {
                        csvStream.GetNextRow(); //This is for header values, we are not comparing for header values

                        rowItems = csvStream.GetNextRow();
                        int rownumber = 1;

                        while (rowItems != null)
                        {
                            if ((rowItems.Length == line.Length) && (rownumber != lineNumber) && (rowItems.Length > 0))
                            {
                                bool b = AreRowItemsEqual(rowItems, line);
                                if (AreRowItemsEqual(rowItems, line) == true)
                                {
                                    if (lineNumber < rownumber)
                                        lineAlreadyVerified = true;
                                    return true;
                                }
                            }
         
                   rowItems = csvStream.GetNextRow();
                            rownumber++;
                        }
                    }
                    catch (Exception e)
                    {                        
                        throw e;
                    }
                }
            }

            return false;
        }

        private static bool AreRowItemsEqual(string[] rowItems, string[] line)
        {
            for (int i = 0; i < rowItems.Length; i++)
            {
                if (rowItems[i] != line[i])
                {
                    return false;
                }
            }
            return true;
        }

Thanks & Regards,

Abdul Aleem Mohammad
St Louis MO - USA


modified 16-Dec-11 12:34pm.

AnswerRe: Comparing array of strings Pin
Morgs Morgan17-Dec-11 8:57
Morgs Morgan17-Dec-11 8:57 
GeneralRe: Comparing array of strings Pin
indian14318-Dec-11 14:03
indian14318-Dec-11 14:03 
GeneralRe: Comparing array of strings Pin
Morgs Morgan18-Dec-11 19:06
Morgs Morgan18-Dec-11 19:06 
GeneralRe: Comparing array of strings Pin
indian14318-Dec-11 21:03
indian14318-Dec-11 21:03 
Questionhow to show a pupup on my parant window. Pin
Jitendra Parida - Jeetu16-Dec-11 1:59
Jitendra Parida - Jeetu16-Dec-11 1:59 
AnswerRe: how to show a pupup on my parant window. Pin
Dennis E White16-Dec-11 5:30
professionalDennis E White16-Dec-11 5:30 
GeneralRe: how to show a pupup on my parant window. Pin
Jitendra Parida - Jeetu17-Dec-11 1:06
Jitendra Parida - Jeetu17-Dec-11 1:06 
GeneralRe: how to show a pupup on my parant window. Pin
Dennis E White17-Dec-11 5:42
professionalDennis E White17-Dec-11 5:42 
GeneralRe: how to show a pupup on my parant window. Pin
Jitendra Parida - Jeetu18-Dec-11 18:39
Jitendra Parida - Jeetu18-Dec-11 18:39 
QuestionHow to deploy my website in server by command Pin
BalasubramanianK15-Dec-11 22:42
BalasubramanianK15-Dec-11 22:42 
QuestionRequest.ServerVariable("REMOTE_HOST") Pin
uspatel15-Dec-11 18:38
professionaluspatel15-Dec-11 18:38 
Questionasp.net vertical menu Pin
ninad_jad15-Dec-11 1:05
ninad_jad15-Dec-11 1:05 
AnswerRe: asp.net vertical menu Pin
nainakarri15-Dec-11 21:00
nainakarri15-Dec-11 21:00 
GeneralRe: asp.net vertical menu Pin
Jitendra Parida - Jeetu23-Dec-11 20:33
Jitendra Parida - Jeetu23-Dec-11 20:33 
AnswerRe: asp.net vertical menu Pin
Jitendra Parida - Jeetu23-Dec-11 20:43
Jitendra Parida - Jeetu23-Dec-11 20:43 
QuestionThe steps of hosting a website? Pin
Jitendra Parida - Jeetu15-Dec-11 0:07
Jitendra Parida - Jeetu15-Dec-11 0:07 
AnswerRe: The steps of hosting a website? Pin
kribo15-Dec-11 3:50
professionalkribo15-Dec-11 3:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.