Created
May 4, 2018 15:30
-
-
Save maacpiash/fa2534876ab186b7ee3ba9ba6d6ffb0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp2.0</TargetFramework> | |
</PropertyGroup> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Collections.Generic; | |
using static System.Console; | |
namespace MergingTesting | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string[] fileNames = Directory.GetFiles(args[0]); | |
string[] AllData; | |
try { AllData = new string[40000]; } | |
catch (Exception x) | |
{ | |
WriteLine(x.ToString()); | |
return; | |
} | |
int fileNumber = fileNames.Length; | |
string[][] FileData = new string[fileNumber][]; | |
try | |
{ | |
for (int i = 0; i < fileNumber; i++) | |
{ | |
FileData[i] = File.ReadAllLines(fileNames[i]); | |
// FileData[fileNumber][lineNumber] | |
WriteLine("Reading from file " + i.ToString() + " completed."); | |
} | |
} | |
catch (Exception x) { WriteLine(x.ToString()); } | |
string oneLine; | |
int eiin, maxLine; | |
for (int i = 0; i < fileNumber; ) | |
{ | |
WriteLine(FileData[i][0]); | |
AllData[0] += FileData[i][0] + ","; | |
maxLine = FileData[i].Length; | |
for (int line = 1; line < maxLine; line++) | |
{ | |
try | |
{ | |
oneLine = FileData[i][line]; | |
eiin = Convert.ToInt32(oneLine.Split(',')[0]); | |
AllData[eiin - 100000] += oneLine + ","; | |
} | |
catch (Exception x) { WriteLine(x.ToString()); } | |
} | |
i++; | |
WriteLine("Processing for file " + i.ToString() + " completed."); | |
} | |
WriteLine("\n" + AllData[0] + "\n"); | |
File.WriteAllLines("Dataset.csv", AllData); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment