Click here to Skip to main content
15,889,595 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How to read everyother line from a CSV file Pin
Blue_Boy19-Dec-08 11:50
Blue_Boy19-Dec-08 11:50 
GeneralRe: How to read everyother line from a CSV file Pin
Tina P22-Dec-08 5:58
Tina P22-Dec-08 5:58 
AnswerRe: How to read everyother line from a CSV file Pin
Christian Graus19-Dec-08 13:45
protectorChristian Graus19-Dec-08 13:45 
GeneralRe: How to read everyother line from a CSV file Pin
Tina P22-Dec-08 6:04
Tina P22-Dec-08 6:04 
GeneralRe: How to read everyother line from a CSV file Pin
Christian Graus22-Dec-08 10:46
protectorChristian Graus22-Dec-08 10:46 
GeneralRe: How to read everyother line from a CSV file Pin
Tina P22-Dec-08 12:20
Tina P22-Dec-08 12:20 
GeneralRe: How to read everyother line from a CSV file Pin
Christian Graus22-Dec-08 14:00
protectorChristian Graus22-Dec-08 14:00 
GeneralRe: How to read everyother line from a CSV file Pin
Tina P25-Dec-08 16:47
Tina P25-Dec-08 16:47 
Hello, Christian...sorry I've been a little sick lately. ANyways, i tried but it won't work quite the way you said.

I swithced to using a TextFieldParser class in Microsoft.VisualBasic.FileIO namespace.

Here's what I'm doing:

using (TextFieldParser textParser = new TextFieldParser(sFileName))
               {
                   textParser.TextFieldType = FieldType.Delimited;
                   textParser.HasFieldsEnclosedInQuotes = false;
                   textParser.SetDelimiters(",");

                   while (!textParser.EndOfData)
                   {
                       Measurements myMeasure = new Measurements();

                       String[] currentRow = textParser.ReadFields();

                       myMeasure._EmplNum= double.Parse(currentRow[0]);
                       myMeasure.DATE = DateTime.Parse(currentRow[1]);
                       myMeasure.Day = Convert.ToString(currentRow[2]);

                       myMeasure.Process(myMeasure);
                   }
               }


where Process is a custom method that is used to instantiate dataContext and then invoke the stored procedure (by calling its method that is generated by LINQ to SQL)

public void Process(Measurements measObj)
        {
            //This is where we implement the logic to process the data.

            MyDataContext dataContext = new MyDataContext();

            dataContext.InsertDaily(measObj.EmplNum, measObj.Date, measObj.Day);
        }


In the first code block where I'm setting up the while loop, i need to set it up in such a way that it'll skip some lines (say first 100) from the CSV file (in other words a few hundred lines of data upfron is useless and needs to be discarded but it'll be part of the CSV coming in) and then when it finally find the place where the actual data begins (lets say a keyWord such as 'Target' or something along those lines, then perhaps I need to do a string.Substring and find it...then starts reading it? I'm not quite sure how to accomplish that keeping the above code in mind.

Any advice.

Thanks a lot
Tina
QuestionWindows Authentication Pin
Jacob D Dixon19-Dec-08 9:51
Jacob D Dixon19-Dec-08 9:51 
QuestionAdding Controls to a updatepanel dynamically Pin
Alomgir Miah A19-Dec-08 9:49
Alomgir Miah A19-Dec-08 9:49 
AnswerRe: Adding Controls to a updatepanel dynamically Pin
Christian Graus19-Dec-08 10:46
protectorChristian Graus19-Dec-08 10:46 
GeneralRe: Adding Controls to a updatepanel dynamically Pin
Alomgir Miah A19-Dec-08 14:28
Alomgir Miah A19-Dec-08 14:28 
GeneralRe: Adding Controls to a updatepanel dynamically Pin
Christian Graus19-Dec-08 16:37
protectorChristian Graus19-Dec-08 16:37 
GeneralRe: Adding Controls to a updatepanel dynamically Pin
Alomgir Miah A19-Dec-08 18:07
Alomgir Miah A19-Dec-08 18:07 
GeneralRe: Adding Controls to a updatepanel dynamically Pin
Christian Graus19-Dec-08 18:23
protectorChristian Graus19-Dec-08 18:23 
GeneralRe: Adding Controls to a updatepanel dynamically Pin
Alomgir Miah A19-Dec-08 18:45
Alomgir Miah A19-Dec-08 18:45 
GeneralRe: Adding Controls to a updatepanel dynamically Pin
Christian Graus19-Dec-08 18:56
protectorChristian Graus19-Dec-08 18:56 
GeneralRe: Adding Controls to a updatepanel dynamically Pin
Alomgir Miah A19-Dec-08 19:13
Alomgir Miah A19-Dec-08 19:13 
GeneralRe: Adding Controls to a updatepanel dynamically Pin
Alomgir Miah A26-Dec-08 6:56
Alomgir Miah A26-Dec-08 6:56 
QuestionCheckBoxList not displaying with first click Pin
Ekjon19-Dec-08 7:47
Ekjon19-Dec-08 7:47 
AnswerRe: CheckBoxList not displaying with first click Pin
Ekjon19-Dec-08 9:01
Ekjon19-Dec-08 9:01 
QuestionRe: CheckBoxList not displaying with first click Pin
Ma tju19-Dec-08 17:04
Ma tju19-Dec-08 17:04 
AnswerRe: CheckBoxList not displaying with first click Pin
Ekjon22-Dec-08 4:05
Ekjon22-Dec-08 4:05 
QuestionCustomer Information in web setup project using web application Pin
shavil19-Dec-08 6:58
shavil19-Dec-08 6:58 
QuestionRegarding Web Setup project using Web Application Pin
shavil19-Dec-08 6:51
shavil19-Dec-08 6:51 

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.