-
Feb 27th, 2012, 09:40 AM
#1
Thread Starter
New Member
Getting data from text files
Hi, I am new to .net vb programing and wanted help in the code for getting data from text files.
I have about 200 .txt files, all in same format as below.
m 998718989898
m 998766990878
F 67
P Thane
So, I want to import this in excel. I know the code for inserting the data in Excel, but no idea of getting the data from text files. This text files are actually used as contact management by the co and has contact name as file name.
Please help by providing code for getting data from a single file, Then I will run it in loop and insert in Excel.
Thanking in advance
-
Feb 27th, 2012, 10:37 AM
#2
Re: Getting data from text files
Something like:
Code:
'open the file
Dim Lines As String() = IO.File.ReadAllLines("c:\mytestfile.txt") 'whatever file you want to read.
Dim Items As String()
'loop through all the lines
For I As Integer = 0 To Lines.Length - 1
'split the line using whatever delimiter the file has
Items = Split(Lines(I), ",")
'use the items array for whatever you want.
Next I
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|