Results 1 to 9 of 9
  1. #1
    SteveG is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    5

    Read text file with LF

    I am using VBA to read in a text file that has only LF as the EOL character. I am having trouble reading up to just the LF but it is going on to the next line. Is there a way to change the definition of the EOL char from CRLF to just LF?

    I am using the Input # statement.
    Are there other alternatives that will handle the LF as the EOL char?

    Thanks,
    SteveG


    Access 2003
    Win 7 64-bit

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You can link to a text file, or you could import it using the import wizard.

  3. #3
    SteveG is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    5
    Thanks Orange.
    But it is an input file to an application I have to process. Its not a straight "load to table" type of file. I have to do some testing against a table in the DB as I read the file.
    Steve

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Right, but if you load the file into a temptable, you can use the tempTable and the other table in queries or vba.

    I'm trying to sort out what exactly you have to do with this fiel before you can actually "apply/process" it against your Access based data.

  5. #5
    SteveG is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    5
    Orange,
    That is a thought, using import into a temp table then process that temptable against my master. This application is part of a Registration System, v2. Attendees fill out a form and it gets entered into DB#1. I control this Access DB from Reg System v1 that processes these forms. I get a complete download every couple of days and update my DB. I go thru the file checking to see if I have the user already. If not, add it, if I do, skip that record.

    My plan was to read the txt file and process as I go. Or, as you say, import the file into a temptable and process it. I need to make it seamless since my wife will be doing most of the work and I have to make it "push button-able". So importing it thru the wizard may not be acceptable.

    I may somehow read the file and replace string 0A for 0D0A, output to a second txt file, then do my processing on that second file. Still thinking about it.

    Thanks for help,
    Steve

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Steve,
    You could try posting a small piece of the text file and maybe someone can work the data to get the CrLf.

  7. #7
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    Perhaps you could use the Replace function to search for the LF and replace it with CRLF.
    Use CHR(10) and CHR(13)&CHR(10).

  8. #8
    SteveG is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    5
    Herfordkc,
    That was my next attempt, try to replace the LF with CRLF.
    SteveG

  9. #9
    SteveG is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    5

    Solved

    Hertfordkc
    I was able to use the Replace function to change the LF to CRLF and works great.
    Solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Err 7-out of memory, read text file
    By dssrun in forum Programming
    Replies: 4
    Last Post: 12-04-2011, 01:06 AM
  2. Replies: 1
    Last Post: 11-05-2010, 04:31 PM
  3. Exporting to Text File
    By blandow in forum Import/Export Data
    Replies: 2
    Last Post: 08-06-2010, 06:02 PM
  4. Replies: 2
    Last Post: 02-27-2010, 06:53 AM
  5. Replies: 2
    Last Post: 10-19-2006, 04:37 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums