The exercise for this learning guide unit was really useful. There are many case in which one could need to look for a file, or just directory information, and this assignment gave us the opportunity to play a little with this.
I had to write something similar some time ago to consolidate thousands of .csv files into one single file. The files were generated by a test system in which only 32 units can be tested simultaneously. For every 32 units, the system generated 4 different files that contains different data.
We were interested only in the calibration files, which have the substring CAL in the file name, so that helped in the task. At that time I used a VB .net console application to do the task.
Below I pasted the code …show more content…
My.Computer.FileSystem.CopyFile("J:\EOL Last Actions\CSV files 2\" & files(counter).ToString, "J:\EOL Last Actions\CSV files\" & files(counter).ToString)
counterLIM = counterLIM + 1
'End If
counter = counter + 1
End While
End If
If activate = 1 Then
While counterWrite <= files2.Length - 1
Console.WriteLine("Consolidated file #: " & counterWrite)
If System.IO.File.Exists("J:\EOL Last Actions\Only LIM files\" & files2(counterWrite).ToString) Then
line = System.IO.File.ReadAllLines("J:\EOL Last Actions\Only LIM files\" & files2(counterWrite).ToString)
If line(1).split(",")(5).Substring(0, 3) = "206" Then
While counterWrite2 <= line.Length - 1
write_IT("J:\EOL Last Actions\", "206_LIM.csv", line(counterWrite2).ToString)
counterWrite2 = counterWrite2 + 1
End While
write_IT("J:\EOL Last Actions\", "206_LIM.csv", "")
write_IT("J:\EOL Last Actions\", "206_LIM.csv", "")
End If
End If
counterWrite2 =