VBA Parse Tab Delimited Text File

raceri

New member
Local time
Today, 23:08
Joined
Jul 3, 2007
Messages
6
Data supplied in tab delimited text file. Unfortunately there are more than 255 columns in the text file and can't directly import into an MS Access table (max 255 columns). Now trying to parse the text file (using VBA) to remove unwanted columns - idea being that once below 255 columns I can load into table. I'm okay with parsing on tab character, chr(9), but I've hit problem if data record contains comma character. VBA INPUT verb appears to consider comma to be a variable delimiter.
Does anyone know a method to read in tab delimited text file so that each record is a single variable regardless of content?
I've got one idea and that's to first import the file into table comprising one memo field. Then I can parse the data records on that table but was hoping to find a method to process the text file directly and not have intermediate table.
Any thoughts appreciated.
 
The way I arrived at importing text files into Access was to develop my own File I/O code reading the file a character at a time.

I taught the code to be line ending agnostic... file may have a mix of Win/Lin/Mac line ending characters.

When the code encounters any of the line endings, then it ships off that line to a line processing function.

It has kept track of the location of all field deliminators, so the line processing function may do "chop chop" knowing exactly where to bust the string up at.
 
Thanks Michael.

Since raising the post, I've discovered that using LINE INPUT rather than INPUT gets around issue of comma characters being treated as variable delimiters in the file.

So I think I'm okay (for the moment!)
 

Users who are viewing this thread

Back
Top Bottom