File system object
-
I have a text file and i want to Split the file into mulitple files based off the city and then create new files with the city name. I am able to read the file and also chnaged the semi colon to a comma in the file. How do i split into multiple files based on city and then create new ones based upon city names This is how the text file looks like(just a junk data) FirstName;LastName;DOB;City;State;Zip Suzy;Adams;05/15/1977;Salt Lake City;UT;84054 Brady;Broom;03/16/1978;Provo;UT;84054 Andrew;Packard;02/06/1980;Salt Lake City;UT;84034 Ralph;Vunderly;01/15/1983;Provo;UT;84023 Thi si my code looks like Imports System Imports System.IO Imports System.Collections Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim objReader As New StreamReader("c:\test.txt") Dim sLine As String = "" Dim arrText As New ArrayList() Do sLine = objReader.ReadLine() If Not sLine Is Nothing Then sLine = Replace(sLine, ";", ",") arrText.Add(sLine) End If Loop Until sLine Is Nothing objReader.Close() For Each sLine In arrText ' Console.WriteLine(sLine) ' MsgBox(sLine) 'Response.Write(sLine) Dim furst As String = arrText(0) Response.Write(furst) Next 'Response.Write(sLine) Response.Write(furst) Console.ReadLine() End Sub End Class
-
I have a text file and i want to Split the file into mulitple files based off the city and then create new files with the city name. I am able to read the file and also chnaged the semi colon to a comma in the file. How do i split into multiple files based on city and then create new ones based upon city names This is how the text file looks like(just a junk data) FirstName;LastName;DOB;City;State;Zip Suzy;Adams;05/15/1977;Salt Lake City;UT;84054 Brady;Broom;03/16/1978;Provo;UT;84054 Andrew;Packard;02/06/1980;Salt Lake City;UT;84034 Ralph;Vunderly;01/15/1983;Provo;UT;84023 Thi si my code looks like Imports System Imports System.IO Imports System.Collections Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim objReader As New StreamReader("c:\test.txt") Dim sLine As String = "" Dim arrText As New ArrayList() Do sLine = objReader.ReadLine() If Not sLine Is Nothing Then sLine = Replace(sLine, ";", ",") arrText.Add(sLine) End If Loop Until sLine Is Nothing objReader.Close() For Each sLine In arrText ' Console.WriteLine(sLine) ' MsgBox(sLine) 'Response.Write(sLine) Dim furst As String = arrText(0) Response.Write(furst) Next 'Response.Write(sLine) Response.Write(furst) Console.ReadLine() End Sub End Class
Create the new file, write data to it, save it. Rinse and repeat until you are done. You can find plenty of sample code on how to do this on Google, just search file handling or files. One trick with ASP.NET though, you have to give IUSR_[Machine Name] access to the folder you want to read/write files to.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo