Results 1 to 3 of 3

Thread: Importing text in my application

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Location
    SLOVENIA, Europe
    Posts
    110

    Question

    I want to create import filter form text files like one in Excel.. My text file in fixed length and columns in file are separated with spaces.

    When i determine witch field is witch I write data into access database. Text file looks like this - but not always:

    08/14/00 10:05AM 28 09 041427330 00:00'48
    08/14/00 10:09AM 11 09 --802-5384-- 00:00'23
    08/14/00 10:15AM 392 09 00:00'50
    08/14/00 10:19AM 392 10 00:00'33
    08/14/00 10:21AM 28 09 216927 00:02'41
    08/14/00 10:26AM 28 09 216927 00:01'12

    It also may look like this:

    08/14/00 10:05AM 28 09 041427330 00:00'48
    08/14/00 10:09AM 11 09 --802-5384-- 00:00'23
    08/14/00 10:15AM 392 09 00:00'50
    08/14/00 10:19AM 392 10 00:00'33
    08/14/00 10:21AM 28 09 216927 00:02'41
    08/14/00 10:26AM 28 09 216927 00:01'12

    Did anyone done this?!

    Thnx
    Ermin Gutenberger

    VB.NET 2010

  2. #2
    Guest
    Hallo

    Have you tried using Instream? I see that a space can act like a delimiter between your values.

    Dim InStream As TextStream
    Dim InFile As string (full path of file)
    Dim FSysIn As New FileSystemObject
    Dim cnn As New ADODB.Connection

    cnn.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source= " & Database & ";"

    Set InStream = FSysIn.OpenTextFile(InFile, ForReading, False, False)'read file (line by line)and extract values

    Set InStream = Nothing
    Set InStream = FSysIn.OpenTextFile(InFile, ForReading, False, False)

    While InStream.AtEndOfStream = False
    strRecord = RTrim(InStream.ReadLine)
    'What ever you want to do further
    Wend


    Set InStream = Nothing
    cnn.Close

    Using the Instr command you can search for the space and read the value between 2 spaces into a variable. Use these variables to Insert it into you database.

    Please let me know if something is unclear.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Location
    SLOVENIA, Europe
    Posts
    110
    I didn't know about Instream. But that is not my problem!

    I want to create import tool for text files (just like in Excel) that user can determine columns for insert in my application.

    Sample of text files (I made the mistake in first thread)

    Code:
    08/14/00 10:05AM 28  09 041427330       00:00'48 
    08/14/00 10:09AM 11  09 --802-5384--    00:00'23 
    08/14/00 10:15AM 392 09                 00:00'50 
    08/14/00 10:19AM 392 10                 00:00'33 
    08/14/00 10:21AM 28  09 216927          00:02'41 
    08/14/00 10:26AM 28  09 216927          00:01'12 
    
    It also may look like this: 
    
    08/14/00 10:05AM  28   09  041427330       00:00'48 
    08/14/00 10:09AM  11   09  --802-5384--    00:00'23 
    08/14/00 10:15AM  392  09                  00:00'50 
    08/14/00 10:19AM  392  10                  00:00'33 
    08/14/00 10:21AM  28   09  216927          00:02'41 
    08/14/00 10:26AM  28   09  216927          00:01'12
    Ermin Gutenberger

    VB.NET 2010

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width