By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,592 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Importing text file structured as report

P: 2
I am trying to find the way to import text file which was desined as report, meaning, even though the file is txt, every page contains repeating report header and report footer.
Can anyone have any ideas?
The only method of solution I was able to come up with so far is to distinguish the first character of each line, whether it is number or alphabet. That way, only lines with numbers would be imported, but I would still need help on how to distinguish them either.
Any idea would be appreciated. Thanks
Apr 29 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 2,364
Hello, dh32470!

What language are you hoping to do this in?

You can if you want, post what you have working thus far for a closer look.


Apr 29 '07 #2

P: 2
Hi, Dokoll,
actually I have not even started yet and wanted to have some lead.
by the way, I am using VB
Apr 29 '07 #3

Expert 5K+
P: 8,434
Hi, Dokoll,
actually I have not even started yet and wanted to have some lead.
by the way, I am using VB
What Dököll (note the dots) meant is, what version?

I'll assume VB6 for the moment.

There may be better ways of achieving this, but one simple way would be to use a variation on this code...
Expand|Select|Wrap|Line Numbers
  1. Dim FileIn As Long, FileOut As Long
  2. Dim Text As String, Char As String * 1
  3. FileIn = FreeFile
  4. Open "Report.Txt" For Input Access Read Shared As FileIn
  5. FileOut = FreeFile ' <-- This must come after the first Open statement!
  6. Open "Data.Txt" For Output Access Write Lock Write As FileOut
  7. Do Until EOF(FileIn)
  8.   Line Input #FileIn, Text
  9.   Char = Left(Text,1)
  10.   If IsNumeric(Char)
  11.     Print #FileOut, Text
  12.   End If
  13. Loop
  14. Close
This is untested. But it should read Report.Txt, rip out any lines that start with a numeric digit, and write them to Data.Txt.
May 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.