473,809 Members | 2,772 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.TransferT ext 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 10042
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.OpenRecordSe t("ImportTable" )

Open "C:\someDir\you rTextFile.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 like them to go down the spreadsheet rather than across for ease of input for the user TIA Tony Williams
4
1718
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 database. I know you can prevent import of queries and modules etc but cant seem to acheive same for tables Any help appreciated Thanks Ian
3
1466
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 character. In addition to this change, to insert a backslash, a double-bacckslash must be emitted. After we discovered this we wrote a short filter program to pipe input data
2
1683
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 can't be in a separate folder. They need to be embedded into the project. Thanks.
3
6242
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 I am very new to) " With cnn1 ..Provider = "microsoft.jet.oledb.4.0" ..Open "dBase
2
1686
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 is seemingly not enough since the using directive in the .aspx.cs file gives the error: "The type or namespace name "MyNamespace" could not be found (are you missing a using directive or an assembly reference?)"
3
12708
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 simple yes/no, so I set up the Excel SS that way. It will not import the data for that field. The rest of the fields import fine. How do I do this please? Bullfrog
1
1787
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 path of database. I would then like to display a list of tables in that database available for import.
0
1283
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 of the gif I imported somehow copyed the frame before the last frame and paste it behind the last frame , and doesn't look right . Here is a picture example with me using SF3 Ryus Kick Gif http://www.freewebs.com/acekombat2/GIF%20HELP.PNG . In the...
2
4455
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 the excel files to a databse using SQL server 2000 enterprise edition? Regards, Ciarán
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10379
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.