Splitting logic of a CSV files into n number of files with .csv extension
Code Snippet:
Code Snippet:
for (int i = 1; i
<= noOfFiles; i++)
{
take = i == 1 ? finsPerCsv + mod :
finsPerCsv;
var fins = AllFins.GetRange(beginIndex, take);
groupByfins.Add(fins);
List<string>
listw = masterData_raw.Where(item => col1Data.Any(category =>
category.col1.Equals(CSVParser2.Split(item)[0].Replace("\"", ""))));
List<Items> list = masterData_cls.Where(item =>
col1Data.Any(category => category.col1.Equals(item.col1)));
var csvFormattedData = list.Select(str =>
"\"" + str.col1
+ "\",\"" + str.col2
+ "\",\"" + str.col3
+ "\",\"" + str.col4
+ "\",\"" + str.col5)
.ToArray();
csvHeader.CopyTo(csvFormattedData,
0);
File.WriteAllLines(filepath, csvFormattedData);
beginIndex = beginIndex + take;
}