Click here to Skip to main content
16,018,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
While reading CSV file, in each line first character is missing…. Here is the case..
CSV file data…
Reported Date	Name	Status
4/19/2011 18:52	INC000005134305	Closed
4/19/2011 18:48	INC000005134250	Closed
4/19/2011 18:11	INC000005134058	Closed

Code..
OpenFileDialog Prp_Opendialogue = new OpenFileDialog();
bool? lBlnFile = Prp_Opendialogue.ShowDialog();
            if ((bool)lBlnFile)
            {
                FileInfo lObjFileInfo = Prp_Opendialogue.File;
            }
StreamReader lObjStreamReader = new StreamReader(Prp_Opendialogue.File.OpenRead());
                bool lBlnIsColumnRow = true;
                while (lObjStreamReader.Read() != null)
                {
                    string lStrLine = lObjStreamReader.ReadLine();
}
………….

Here in this lStrline, I am getting “/19/2011 18:52, INC000005134305, Closed”, Here you can see 4 is missing. How can I get this…
Any ideas please..
Sreenath
Posted
Updated 16-May-11 20:44pm
v2
Comments
Sandeep Mewara 17-May-11 2:44am    
You are not new here, yet you dont format your code part using PRE tags. Please do so from next time.
Sreenath Gv 17-May-11 2:46am    
sure...

When you call lObjStreamReader.Read() you read the first character. Don't make that call and your '4' won't be missing.

StreamReader lObjStreamReader = new StreamReader(Prp_Opendialogue.File.OpenRead());
bool lBlnIsColumnRow = true;
string lStrLine;
while ((lStrLine = lObjStreamReader.ReadLine()) != null)
{
    // do something with lStrLine
}
 
Share this answer
 
Comments
Sreenath Gv 17-May-11 4:20am    
thanks mark.
adityajha 10-Jul-12 2:51am    
Thanks Mark.
Sreenath, see Loadin a CSV file into a DataGrid in Silverlight 4 Application[^]; I gave you the answer 4 days ago.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900