Gurus!
I am memory mapping a huge, 1 GB csv file, splitting it into 20 equal sized views, and then trying to process each view line by line and output the results into a text file. I have written the code to split the file into view, but unable to figure out the code to read lines from each view, process it and then output the results to a text file. Following is the code I am writing to memory map my csv file and split it into views:
string csvFilePath = @"C:\MyPath\MyLargeCSVFile.csv"; FileInfo f = new FileInfo(csvFilePath); // Geting size of each of the 20 views here long fragmentSize = f.Length/20; using (var mmf = MemoryMappedFile.CreateFromFile(csvFilePath, FileMode.Open)) { List<MemoryMappedViewAccessor> mmv = new List<MemoryMappedViewAccessor>(); for (int i = 0; i < 20; i++) { using (MemoryMappedViewAccessor mmFragment = mmf.CreateViewAccessor(i * fragmentSize, fragmentSize, MemoryMappedFileAccess.Read)) { mmv.Add(mmFragment); } } }
What I am trying to do is to get each 'mmFragment' from the list mmv, read it line by line, do some basic string processing operations (such as split) on each line, and then output the results to a text file.
Could my Gurus please help me here?
Novice Kid