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.9k
LINQ Error IN ForEach
Mar 15 2018 9:33 AM
Hi,
I am trying to combile multiple csv files to one, getting error as - in code
'IEnumerable<string[]>' does not contain a definition for '
ForEach
' and no extension method 'ForEach' accepting a first argument of type 'IEnumerable<string[]>' could be found (are you missing a using directive or an assembly reference?)
CODE -
public
static
void
CombineMisMatchedCsvFiles(
string
[] filePaths,
string
destinationFile,
char
splitter =
','
)
{
HashSet<
string
> combinedheaders =
new
HashSet<
string
>();
int
i;
// aggregate headers
for
(i = 0; i < filePaths.Length; i++)
{
string
file = filePaths[i];
combinedheaders.UnionWith(File.ReadLines(file).First().Split(splitter));
}
var hdict = combinedheaders.ToDictionary(y => y, y =>
new
List<
object
>());
string
[] combinedHeadersArray = combinedheaders.ToArray();
for
(i = 0; i < filePaths.Length; i++)
{
var fileheaders = File.ReadLines(filePaths[i]).First().Split(splitter);
var notfileheaders = combinedheaders.Except(fileheaders);
File.ReadLines(filePaths[i]).Skip(1).Select(line => line.Split(splitter)).
ForEach
(spline =>
{
for
(
int
j = 0; j < fileheaders.Length; j++)
{
hdict[fileheaders[j]].Add(spline[j]);
}
foreach
(
string
header
in
notfileheaders)
{
hdict[header].Add(
null
);
}
});
}
Reply
Answers (
1
)
google map Check the LatLng value is inside the Radius..?
Get GlyphName from ttf files using C#