473,657 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2155
"NathanB" <na************ **@hotmail.comw rote in
news:11******** *************@m 73g2000cwd.goog legroups.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
2745
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, a module change its interface or its implementation in a fundamental way (an example: wxPython). This, I think, can be resolved by allowing an user to explicitly say what version of a module it wants (sush as version numbers in Linux shared...
17
1873
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 environment variables which select the desired behaviour, and the module inspects those variables to determine the mode in which it should set itself up. I would prefer a pure Python solution, rather than one which depends on external state. Can you...
0
2708
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 to obtain SHIP_wrap.cpp and SHIP.py; the latter contains the line "import _SHIP". I compile SHIP_wrap.cpp and a bunch of files into a DLL which I have the
1
2022
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, but still seem to show-up when I go to import a file. The reason for this is Lusers.. If I don't limit the list to the table they import into, they will import into the wrong table, or even import into a new table (Then complain there Info is...
0
1433
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 "calling scratch card" that customers enters on our website. Script accepts the long code, validates it with a database, than offers a customer to create a login/pass to enter
1
7376
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 adding some registry values when you move the cursor over some file in Win Explorer, the shell will create object from your class and will call IPersistFile::Load. Well here is the problem - in my situation it is not called. The only method that is...
10
3758
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 be run as commands to a file with no extension. This allows other programs to use the command as an interface, and I can re-write the program in some other language
0
2078
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 import error below. Same error with PythonWin as my IDE and everything works using python 2.4-- with IDLE and without, mySQLdb is loaded with out error. Below is the IDLEscreen capture Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win32...
3
12294
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 interface. So I've tried to split code into separate files and in windows as I remember worked file when i wrote eg. import myFile but now in Ubuntu it says Module not found. (I'm using Ubuntu and I've installed python 2.5 and wxPython 2.8.4, and I'm...
0
8385
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...
0
8303
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8723
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8502
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
8602
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.