Showing posts with label lines. Show all posts
Showing posts with label lines. Show all posts

Wednesday, March 28, 2012

text file

I have a text file that i have to read and insert into a database table. The
files has over 30 lines of data in it, I need to start inserting data from
line 8 in the file. How can I start inserting the data from line 8 of my tex
t
file? So from line 1-7 are read only (headers) and starting with line 8 need
s
to be inserted into the table.Hi,
you could use StreamReader which has ReadLine method. You could use it to
skip the first 8 lines, and then go about teading it line by line.
StreamReader.ReadLine
http://msdn.microsoft.com/library/d...adLineTopic.asp
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:15EBF9C2-7859-4EEF-A33E-8A64131ABCCC@.microsoft.com...
>I have a text file that i have to read and insert into a database table.
>The
> files has over 30 lines of data in it, I need to start inserting data from
> line 8 in the file. How can I start inserting the data from line 8 of my
> text
> file? So from line 1-7 are read only (headers) and starting with line 8
> needs
> to be inserted into the table.
>

Monday, March 26, 2012

text file

I have a text file that i have to read and insert into a database table. The
files has over 30 lines of data in it, I need to start inserting data from
line 8 in the file. How can I start inserting the data from line 8 of my text
file? So from line 1-7 are read only (headers) and starting with line 8 needs
to be inserted into the table.Hi,

you could use StreamReader which has ReadLine method. You could use it to
skip the first 8 lines, and then go about teading it line by line.

StreamReader.ReadLine
http://msdn.microsoft.com/library/d...adLineTopic.asp

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:15EBF9C2-7859-4EEF-A33E-8A64131ABCCC@.microsoft.com...
>I have a text file that i have to read and insert into a database table.
>The
> files has over 30 lines of data in it, I need to start inserting data from
> line 8 in the file. How can I start inserting the data from line 8 of my
> text
> file? So from line 1-7 are read only (headers) and starting with line 8
> needs
> to be inserted into the table.

Text File Reverse Read?

Does anyone know of a way to accomplish reading a text file from end to beginning? Like if you wanted to read the last 200 lines from a log file to display on the screen... Can this be done through the framework classes or does this have to be accomplished via a hand made function?I just don't know how to read backwards but you can solve this by writing it backwards and then you can read normally.

To write use:


Dim file As String = "c:\test.txt" 'this must be the name and path of your file
Dim arq As New StreamReader(file)
Dim log_data As String ' this is the content you want to add
Dim cont As String = log_data + arq.ReadToEnd
arq.Close()
Dim arq2 As New StreamWriter("c:\test.txt")
arq2.WriteLine(cont)
arq2.Close()

Then you may read it from the start to the end. You just must to check it's performance.