473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Import Interface File

Hi there,

I have a text file (flat file) which I would like to import on a
regular basis into Access. The text file contains 2 record types,
header (prefixed with RHD) and detail (prefixed with RDT). Each
recordtype has a unique structure.
-------------------------------------------------------------------------------
For example line one might read:
RHD123456ABCDEF

Characters 1-3 is record type, characters 4-9 is field X, characters
4-15 is field Y
-------------------------------------------------------------------------------
Line 2 onwards are detail records for line 1:
RDT999ABC99

Characters 1-3 is record type, characters 4-6 is field X, characters
7-9 is field Y, characters 10-11 is field Z.
-------------------------------------------------------------------------------

Is it possible to interrogate each line of the file to determine the
recordtype and subsequently import the fields into a table using a
predefined record structure?

I am looking for a solution which will work along the following lines:
1. Check folder for interface file
2. Read file line x
3. Determine recordtype (RHD or RDT)
4. If recordtype is RHD then save each field (X,Y) in associated
variables
5. If recordtype is RDT then import to table using RHD variables and
RDT fields.
6. After successful import move file to "completed" folder

I have had experience importing deliminated files but never attempted
to import multiple record types in a single file.

I hope this makes sense.

Any help/advice will be much appreciated.

Regards,
Nathan

Sep 4 '06 #1
1 2129
"NathanB" <na**************@hotmail.comwrote in
news:11*********************@m73g2000cwd.googlegro ups.com:
Hi there,

I have a text file (flat file) which I would like to import on
a regular basis into Access. The text file contains 2 record
types, header (prefixed with RHD) and detail (prefixed with
RDT). Each recordtype has a unique structure.
--------------------------------------------------------------
-
---------------- For example line one might read:
RHD123456ABCDEF

Characters 1-3 is record type, characters 4-9 is field X,
characters 4-15 is field Y
--------------------------------------------------------------
-
---------------- Line 2 onwards are detail records for line 1:
RDT999ABC99

Characters 1-3 is record type, characters 4-6 is field X,
characters 7-9 is field Y, characters 10-11 is field Z.
--------------------------------------------------------------
-
----------------

Is it possible to interrogate each line of the file to
determine the recordtype and subsequently import the fields
into a table using a predefined record structure?

I am looking for a solution which will work along the
following lines: 1. Check folder for interface file
2. Read file line x
3. Determine recordtype (RHD or RDT)
4. If recordtype is RHD then save each field (X,Y) in
associated variables
5. If recordtype is RDT then import to table using RHD
variables and RDT fields.
6. After successful import move file to "completed" folder

I have had experience importing deliminated files but never
attempted to import multiple record types in a single file.

I hope this makes sense.

Any help/advice will be much appreciated.

Regards,
Nathan
There are a couple of ways to do this. one is to import the file
into a temporary file with two fields, the first is an
autonumber and the second is the full line of text from the
import. You then build queries that parse the lines and move
tham to the proper destinations, using a lot of mid() functions.
The autonumber is used to keep references between the two
destinations; you can't set a relationship(1) because they
aren't equal, but you can use a whewre clause.

The other is to read the file using good old open() and get()
statements from primitive basic, They are still there in Visual
Basic.

(1) you can set the relationship if you write the sql, but not
if you use the query builder. A Where clause works well, just a
little slower.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Sep 4 '06 #2

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

Similar topics

16
by: Manlio Perillo | last post by:
Hi. I'm a new user of Python but I have noted a little problem. Python is a very good language but it is evolving, in particular its library is evolving. This can be a problem when, ad example,...
17
by: Jacek Generowicz | last post by:
I have a module whose behaviour needs to be configurable. The module needs to decide, the first time it is imported, beteween alternative interfaces it presents. Currently, I set some...
0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
1
by: carverk | last post by:
Greetz All, Is there a way to hide Tables from being displated by the Import Wizard? I have already did the Right mouse click | Properties | Hide Option. The tables disappear from the DB Window,...
0
by: job kazan | last post by:
Can anyone suggest the best and easiest platform for the following job, possible freelancer and approximate budget for this: "It must be a script that has as an input a long code from the...
1
by: Plamen | last post by:
Hi , I need to change the ToolTip in Windows explorer that is shown when the cursor is over a file. Here is how it should work: you create a class that imports IPersistFile and IQueryInfo. After...
10
by: Ben Finney | last post by:
Howdy all, Question: I have Python modules named without '.py' as the extension, and I'd like to be able to import them. How can I do that? Background: On Unix, I write programs intended to...
0
by: Michael Boldin via alt email | last post by:
I installed python 2.5 and used the win package for installing MySQLdb. (Iam running Windows XP) Everything works as expected using python directly (Windows command shell) but using IDLE gives the...
3
by: SMALLp | last post by:
Hy! I'm new in Linux, and i feel little less newer in python. I need advice and help. I'm making an application witch purpose is irrelevant. It has a lot of code for now and I've only made...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...
0
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,...

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.