I need to loop through set of files and check if it is comma delimited or not in C#.I am very new to C#.Please help me with this.
Thanks in advance.
I need to loop through set of files and check if it is comma delimited or not in C#.I am very new to C#.Please help me with this.
Thanks in advance.
Here's a quick Console app that will take a directory, scan the directory for all files, then iterate through them and return a percentage of lines containing commas -vs- the total lines in the file. As has been pointed out, there are CSV libraries you can validate against. This is just a quick example to get you started.
To use this, create a new Console App project in Visual Studio and name it "TestStub" then copy and past this into the "Program.cs" file.
}
As someone already pointed out it is not going to be easy solution. It could be very easy if every comma delimited file had a specified extension (for example: csv). If not the following algorigthm should work:
System.IO.Directory
andSystem.IO.File
andSystem.IO.DirectoryInfo
andSystem.IO.FileInfo
Regular expressions are a bit hard to learn at the beginning but it should pay back after some time.