Karen,
If this is a delimited file perhaps you can use the ODBC TEXT DRIVER. Here is
some information
RDO may be used with the ODBC Text driver to open and browse a delimited
text file. Although this
example is geared to Access DB. It is easily adapted to RBase ODBC.
MORE INFORMATION
The Text ODBC driver relies on the Microsoft Jet 32-bit IISAM driver
(MSText35.... The Text ODBC driver relies on the Microsoft Jet 32-bit IISAM
driver
(MSText35.dll) that provides the services required for accessing text
files. You can either link/attach to a Microsoft Access database or
directly open text files. Because RDO must use Jet to access the text file,
you will incur the additional overhead associated with loading Jet.
NOTE: This requires a Schema.ini file in the same path as the delimited
text file. You must change the columns in the Schema.ini file to correspond
to your delimited file. Also, you must change the path in the connect
string to the correct path for your file.
To create a schema.ini file, use a simple text editor such as Notepad.
Below are the schema.ini entries for the SAMPLE2.TXT file listed at the
bottom of this article:
[SAMPLE2.TXT]
ColNameHeader = False
Format = CSVDelimited
CharacterSet = ANSI
Col1=ProductID short
Col2=ProductName char width 30
Col3=QuantityPerUnit char width 30
Col4=UnitPrice currency
Col5=Discontinued bit
For more information on Schema.ini, see the REFERENCES section of this
article.
Back to the top
Step-by-Step Example
1. Open Visual Basic, and create a new Project. Form1 is created by
default.
2. Set a reference to Microsoft Remote Data Object 2.0 with the
Project-References menu selection.
3. Paste the following code in the Form-Load event:
Dim cn As New RDO.rdoConnection
Dim en As RDO.rdoEnvironment
Dim rs As RDO.rdoResultset
Dim fld As RDO.rdoColumn
Set en = rdoEngine.rdoEnvironments(0)
With cn
.CursorDriver = rdUseOdbc
'The DBQ parameter below, is the path to your
'Comma Delimited file(s). You may open multiple files
'on the same connection in this path.
.Connect = "DRIVER={Microsoft Text Driver (*.txt;" & _
" *.csv)};DBQ=E:\Samples\Text\CommaDelimited;"
.EstablishConnection rdDriverNoPrompt, False
End With
'Jet uses '.' internally as an identifier for table names,
'such as database.table. Jet eliminates ambiguity by mapping '#'
'as the delimiter for external files.
Set rs = cn.OpenResultset("select * from [sample2#txt]")
While Not rs.EOF
For Each fld In rs.rdoColumns
Debug.Print fld.Name & "=" & fld.Value
Next fld
rs.MoveNext
Wend
NOTE: In the example above, DBQ is not a valid parameter of the RemoteData
control or the rdoConnection object's Connect property. It is supported by
the Microsoft Jet database engine, and not by the ODBC driver.
You could copy and paste the following delimited file example into Notepad
and save it as Sample2.txt. You could then modify the DBQ path, above, to
point to the comma delimited file Sample2.txt.
1,Chai,10 boxes x 20 bags,$18.00,False
2,Chang,24 - 12 oz bottles,$19.00,False
3,Aniseed Syrup,12 - 550 ml bottles,$10.00,False
4,Chef Anton's Cajun Seasoning,48 - 6 oz jars,$22.00,False
5,Chef Anton's Gumbo Mix,36 boxes,$21.35,True
6,Grandma's Boysenberry Spread,12 - 8 oz jars,$25.00,False
7,Uncle Bob's Organic Dried Pears,12 - 1 lb pkgs.,$30.00,False
(This will give you seven records to test with in the sample code.)
NOTE: Make sure when you paste it in Notepad that you do not leave any
blank lines at the top of the file.
You may choose an alternative to the comma delimiter by indicating the
delimiter in the Schema.ini file e.g. Format = Delimited(*). You can use
any character for the delimiter except the double (") quotation mark.
This same technique can be applied to fixed-width files by indicating
'FixedLength' for the Format, such as Format = FixedLength.
REFERENCES
"Working with Text Files", MSDN
"Using DAO to Connect to ODBC Data Sources", MSDN.
"RDO Compared to Microsoft Jet/DAO", MSDN.
"Text Data Source Initialization Settings", MSDN.
"External ISAM Driver Components", MSDN.
"Understanding Schema.ini Files", MSDN.
For additional information, please see the following article in the
Microsoft Knowledge Base:
155512 (http://support.microsoft.com/kb/155512/EN-US/ ) : ACC: How to Create
a Schema.ini File Programmatically. Jim Bentley
American Celiac Society
[email protected]
tel: 1-504-737-3293
________________________________
From: James Bentley <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Wed, November 11, 2009 2:25:43 PM
Subject: [RBASE-L] - Re: Need help with an import filetype
Karen,
Have you tried to open it in Microsoft Word. You may need to rename to a .TXT
extension.
This might give you a clue as to what the file really looks like.
Jim Bentley
American Celiac Society
[email protected]
tel: 1-504-737-3293
________________________________
From: "[email protected]" <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Wed, November 11, 2009 11:50:39 AM
Subject: [RBASE-L] - Need help with an import filetype
I'm trying to import a file which was described to me as a "unicode text file",
although it is saved with an .xls extension. You can bring the file up in
Excel (it uses a tab delimiter to do it) and re-save it as another format, and
that's what we've been doing. But they'd rather not have to do this. I am
unable to find an import type that will bring this file in. Ascii tab
delimited doesn't work because it is not an ascii file. This is the client
that's still in 6.5, but I can't find anything in 7.6 either.
If anyone would like to give this a shot, email me privately and I can ship you
the file.
Karen