TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ms_ Dev
NA
236
91.6k
Skip 1st line while reading from csv file.
Oct 18 2016 4:13 AM
Hi Everyone,
I have the following code -
static
void
Main(
string
[] args)
{
Console.Clear();
string
fileName =
"\\file1.csv"
;
fileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + fileName;
var fileStream =
new
FileStream(fileName, FileMode.Open, FileAccess.Read);
using
(var streamReader =
new
StreamReader(fileStream, Encoding.UTF8))
{
string
line,ID, UniqNumber;
while
((line = streamReader.ReadLine()) !=
null
)
{
ID = line.Length >= 1 ? line.Substring(1,7) :
string
.Empty;
UniqNumber = line.Length >= 1 ? line.Substring(8, 12) :
string
.Empty;
Console.WriteLine(
"ID={0},UniqNumber={1}"
, ID, UniqNumber);
}
}
Console.ReadKey();
}
I want to skip the first row while performing the operation. PLease help to omit the first line as it may contains invalid data.
Thanks,
Reply
Answers (
4
)
change permanently Image path in asp.net c#
Perform Join on three tables using EF