Delete headers from csv file and export to a txt file

Hi guys:
Im trying to create a simple utility using vb.net console application that will generate a exe. That I will trigger after 3 files have been exported to a directory. The utility will look for 3 files: RTI.csv, TLG.csv and ALP.csv, will open the files take the first row out which is a header and then resave or export it to a TXT file, renaming them to RTI.txt, TLG.txt and ALP.txt. of course with not header and not leaving a gap or empty space were the header was. Im a sql developer just with some experience in vb.net. I read that I can use a dataset to do this but not to sure how to, I will really appreciate any tips or ideas.

Thanks A lot!
Oneill0003Asked:
Who is Participating?
 
Wayne Taylor (webtubbs)Connect With a Mentor Commented:
Hi Oneill0003,

The quickest and easiest way is probably to use something like this....

        Dim FolderPath As String = "C:\"
        Dim FileNames() As String = {"RTI.csv", "TLG.csv", "ALP.csv"}
        For Each File As String In FileNames
            Dim sr As New StreamReader(FolderPath & File)
            Dim FileText As String = sr.ReadToEnd
            sr.Close()
            Dim sw As New StreamWriter(FolderPath & File.Replace("csv", "txt"), False)
            sw.Write(FileText.Substring(FileText.IndexOf(vbLf)))
            sw.Close()
        Next

Regards,

Wayne
0
 
Oneill0003Author Commented:
Hi Webtubbs:
I apologies for the delay I did try your code and it was a great help.
Thanks for the help!
0
All Courses

From novice to tech pro — start learning today.