hi experts i have a csv file which look like this


i am reading the file like this

StreamReader sr = new StreamReader(@"C:\Documents and Settings\jitendra\Desktop\RIC_SELL_080318.csv");

string strline="";
if(values.Lenght >3 )

so on doing this i get the code coloumn data but it is not giving the complete records from the file , and what i want is to read this file using array and only want to get the data of code coloumn and sort it in descending order. so can you plz help me plz its urgent thanking you in advance....

Recommended Answers

Add the values in List<String> and use some List methods like Reverse,....

Jump to Post

All 4 Replies

Add the values in List<String> and use some List methods like Reverse,....

hey Rammy i have tried list and my code worked i am experiencing a problem with stream writer it is not reading the whole records of the file my original file contains 361 recors including header but the code which i have written using streamReader.ReadLine() method does not reads the whole file it skips the last 83 records it is only giving me 278 records. On using streareader.ReadToEnd gives me the whole records but then it does not gives the value of array. so where i am making mistake i am not getting see i am sending my code have a look at it and please help me....

StreamReader sr= new StreamReader(@"C:\Documents and Settings\jitendra\Desktop\RIC_SELL_080318.csv");
            StreamWriter sw = new StreamWriter(@"C:\list.txt");

            string strline = "";
            string[] values = null;
            IList<string> list = new List<string>();
IList<string> list = new List<string>();
 while (!sr.EndOfStream)
strline = sr.ReadLine();
values = strline.Split(',');
if (values.Length > 3)
IComparer myComparer = new myReverserClass();  
            string[] final = new string[list.Count]; 
            Array.Sort(final, myComparer); 
            foreach (string var in final)
public class myReverserClass : IComparer 
                // Calls CaseInsensitiveComparer.Compare with the parameters reversed.
                int IComparer.Compare(Object x, Object y)
                return ((new CaseInsensitiveComparer()).Compare(y, x));


My data is in this form i need to arrange it as name,age ,place and it should be stored
please send the code in C# send to boss.deepak@gmail.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.