473,503 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing A Tab-Delimited Text File Containing Double Quotes

I'm using DoCmd.TransferText acImportDelim... to import a tab-delimited
..txt file using an Import Specification file and that works fine. The
problem is that a few records could have double-quotes in one of the
ten fields and that causes an "Unparsable Record" error and the
remaining fields for those records are blank. This is part of a
process that should not require manual intervention i.e. using an
editor to remove the ". Is there a workaround that anyone knows of?
Thanks, Sheldon Potolsky

Dec 7 '06 #1
2 10015
One solution is to use VBA code instead of Docmd. Here is a routine for
reading a text file using VBA:

Sub ReadText()
Dim DB As DAO.Database, RS As DAO.Recordset
Dim str1 As String, str2() As String
Dim i As Integer

Set DB = CurrentDB
Set RS = DB.OpenRecordSet("ImportTable")

Open "C:\someDir\yourTextFile.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, str1
str2 = Split(str1, vbTab)
RS.AddNew
For i = 0 to Ubound(str2)
RS(i) = str2(i)
Next
RS.Update
Loop
Close #1
RS.Close
End Sub

What I am doing here is reading each line of the text file using the
Line Input method. This will read the entire line into str1. Then I
parse str1 into an array using the Split function. str2 is a string
array. Since your data is tab delimited I specify vbTab as the
delimeter for the Split function. Then I use DAO code to write the data
to a table. This assumes you have a table with the same number of
fields as the data in the textfile. DAO does not care if you have
quotes or any other weird symbols. I could do the same thing using Sql
which is a more efficient, but it becomes more complex for dealing with
quotes and weird symbols.

Using code is more reliable than DoCmd.Transfer...

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Dec 7 '06 #2

Thanks Rich.
Sheldon

Dec 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
423
by: Tony Williams | last post by:
Is it possible to import a spreadsheet from Excel where the rows contain the field names rather than the columns? I'm creating an Excel spreadsheet but there are over 50 items to import and would...
4
1698
by: Ian Davies | last post by:
Is there a way to stop importing tables from an mde database to a newly created database. I wish to protect the data in the mde so that it can only be accessed through a particular front end...
3
1450
by: Mental | last post by:
Hello, perhaps you may have some advice. The postgresql documentation for COPY FROM INFILE suggests that high-ascii characters be encoded to a backslash followed by the octal value for the...
2
1667
by: VMI | last post by:
How can I import a 900x600 image into my imagelist? The problem is that imageList.ImageSize goes to 255x255 and these images will be used as background for 800x600 (and higher) resolutions. They...
3
6216
by: Donald Grove | last post by:
I need to get data from a table in .dbf format. I try importing it, but get "external table not in expected format". So I tried this VB code to see if I could get at my records with ADO (which...
2
1664
by: Ebbe Kristensen | last post by:
Hi All I am trying to get access to an assembly in an ASPX project. I have added the assembly to GAC using gacutil and added an "%@Import namespace = "MyNamespace" %" to the .aspx file but this...
3
12666
by: Bullfrog | last post by:
I have a database that one of the fields is a check box. Basically a check means yes, no check means no. I am trying to import data from an Excel spreadsheet. I assumed the check box would use a...
1
1760
by: G Gerard | last post by:
Hello I am creating a wizard so a user can import data from other type of databases (DBase IV, Paradox etc...) into an Access mdb. The first step would require the user to choose the type and...
0
1258
by: AceKombat | last post by:
Hi ! I'm having a problem after importing a gif into flash . When the gif is imported , it shows in the library tab and looks as it is successfully imported , but no , for some reason the last frame...
2
4429
by: ciaran.hudson | last post by:
Hi I have multiple excel files of the same format in a directory. They are called book1.xls, book2.xls, book3.xls and so on. What is the easiest way to import the tab named sheet1 from each of...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.