We have despatch process which kicks out picking information into text
files at hourly intervals.
The text files are named sequentially by process; 'ABC.txt',
'ABC01.txt', 'ABC02.txt' for one process, or 'XYZ.txt', 'XYZ01.txt' for
another process.
The folder contents would look like this;
ABC.txt
ABC01.txt
ABC02.txt
XYZ.txt
XYZ01.txt
XYZ02.tx
AAA.txt
AAA01.txt
AAA02.txt
I have created a database which has a link to the first file, the one
that does not contain a number in the filename.
I run a bit of code to import the data from the linked file.
I then go into Explorer, manually delete 'ABC.txt', and rename
'ABC01.txt' to 'ABC.txt'.
I do this until all the text files have been imported, for each process
- yikes!
The import of each set of process text files requires different bits of
code to manipulate them into the database.
So a different query would work on the ABC data to the query that works
on the XYZ data.
As I sit and peck away at the keyboard like a psychotic pigeon, doing
this manually, I realise this is a laborious method and need to refine
it!
My thoughts;
I think I need a SELECT CASE structure to determine the filename and
therefore the correct code to manipulate the data into the application.
Where I need some guidance, is how to automate this!!
I want to basically automate what I do manually - import data from
ABC.txt, delete the text file, grab ABC01.txt rename it to ABC.txt,
import it, delete the ABC.txt text file, grab ABC02.txt, rename it to
ABC.txt and so on!
Anyone have any ideas/thoughts as to which way I go with this?
Any comments are gratefully appreciated.
Thanks in advance.
Phil 2 2699
Assuming that there will always be a 2 digit sequence number if there is a
sequence number, something like the following untested air-code should work:
Dim intDecimal As Integer
Dim strFolder As String
Dim strFile As String
Dim strFileNoSequence As String
strFolder = "C:\SomeFolder\SomeSubFolder\"
strFile = Dir(strFolder & "*.txt")
Do While Len(strFile) > 0
intDecimal = InStr(strFile, ".txt")
If IsNumeric(Mid(strFile, intDecimal-2, 2)) Then
strFileNoSequence = Left(strFile, intDecimal - 3) & ".txt"
Name strFolder & strFile As strFileNoSequence
Else
strFileNoSequence = strFile
End If
' At this point, you can import strFolder & strFileNoSequence
Kill strFolder & strFileNoSequence
strFile = Dir()
Loop
--
Doug Steele, Microsoft Access MVP http://I.Am/DougSteele
(no e-mails, please!)
"Phil Latio" <ph********@lycos.co.uk> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... We have despatch process which kicks out picking information into text files at hourly intervals.
The text files are named sequentially by process; 'ABC.txt', 'ABC01.txt', 'ABC02.txt' for one process, or 'XYZ.txt', 'XYZ01.txt' for another process.
The folder contents would look like this; ABC.txt ABC01.txt ABC02.txt XYZ.txt XYZ01.txt XYZ02.tx AAA.txt AAA01.txt AAA02.txt
I have created a database which has a link to the first file, the one that does not contain a number in the filename.
I run a bit of code to import the data from the linked file. I then go into Explorer, manually delete 'ABC.txt', and rename 'ABC01.txt' to 'ABC.txt'. I do this until all the text files have been imported, for each process - yikes!
The import of each set of process text files requires different bits of code to manipulate them into the database. So a different query would work on the ABC data to the query that works on the XYZ data.
As I sit and peck away at the keyboard like a psychotic pigeon, doing this manually, I realise this is a laborious method and need to refine it!
My thoughts; I think I need a SELECT CASE structure to determine the filename and therefore the correct code to manipulate the data into the application.
Where I need some guidance, is how to automate this!! I want to basically automate what I do manually - import data from ABC.txt, delete the text file, grab ABC01.txt rename it to ABC.txt, import it, delete the ABC.txt text file, grab ABC02.txt, rename it to ABC.txt and so on!
Anyone have any ideas/thoughts as to which way I go with this?
Any comments are gratefully appreciated.
Thanks in advance.
Phil
Hi Douglas,
sorry for the delay in responding to your reply, but just to say thanks
for the pointers and code snippet - it has really helped me out!
Many thanks
Phil
Douglas J. Steele wrote: Assuming that there will always be a 2 digit sequence number if there is a sequence number, something like the following untested air-code should work:
Dim intDecimal As Integer Dim strFolder As String Dim strFile As String Dim strFileNoSequence As String
strFolder = "C:\SomeFolder\SomeSubFolder\" strFile = Dir(strFolder & "*.txt") Do While Len(strFile) > 0 intDecimal = InStr(strFile, ".txt") If IsNumeric(Mid(strFile, intDecimal-2, 2)) Then strFileNoSequence = Left(strFile, intDecimal - 3) & ".txt" Name strFolder & strFile As strFileNoSequence Else strFileNoSequence = strFile End If
' At this point, you can import strFolder & strFileNoSequence
Kill strFolder & strFileNoSequence strFile = Dir() Loop
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Phil Latio" <ph********@lycos.co.uk> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... We have despatch process which kicks out picking information into text files at hourly intervals.
The text files are named sequentially by process; 'ABC.txt', 'ABC01.txt', 'ABC02.txt' for one process, or 'XYZ.txt', 'XYZ01.txt' for another process.
The folder contents would look like this; ABC.txt ABC01.txt ABC02.txt XYZ.txt XYZ01.txt XYZ02.tx AAA.txt AAA01.txt AAA02.txt
I have created a database which has a link to the first file, the one that does not contain a number in the filename.
I run a bit of code to import the data from the linked file. I then go into Explorer, manually delete 'ABC.txt', and rename 'ABC01.txt' to 'ABC.txt'. I do this until all the text files have been imported, for each process - yikes!
The import of each set of process text files requires different bits of code to manipulate them into the database. So a different query would work on the ABC data to the query that works on the XYZ data.
As I sit and peck away at the keyboard like a psychotic pigeon, doing this manually, I realise this is a laborious method and need to refine it!
My thoughts; I think I need a SELECT CASE structure to determine the filename and therefore the correct code to manipulate the data into the application.
Where I need some guidance, is how to automate this!! I want to basically automate what I do manually - import data from ABC.txt, delete the text file, grab ABC01.txt rename it to ABC.txt, import it, delete the ABC.txt text file, grab ABC02.txt, rename it to ABC.txt and so on!
Anyone have any ideas/thoughts as to which way I go with this?
Any comments are gratefully appreciated.
Thanks in advance.
Phil This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Kolvereid |
last post by:
How does one import data INTO a table. I am forced to read files (\i)
w/ a ton of insert statements. I am trying to import approx 800 lines
into the table. However, I must bundle them into a...
|
by: Dan |
last post by:
Could someone please help me with auto importing a series of data
files into an Access table. I tried to follow code given below in a
previous messagebut i'm getting error messages.
Here's my...
|
by: Johnny Meredith |
last post by:
I have seven huge fixed width text file that I need to import to Access.
They contain headers, subtotals, etc. that are not needed. There is also
some corrupt data that we know about and can...
|
by: John Marble |
last post by:
I have around 400 excel files filled with data that I need to import
in ACCESS. The tricky part is that they must be imported one at time,
and properly corrected before importing the next one. I...
|
by: Avi |
last post by:
Hi
I need to read in a large set of text files (9GB+ each) into a database
table based on fixed width lengths.
There are several ways to complete this, but I am wondering if anyone has...
| |
by: Martin Unsal |
last post by:
I'm using Python for what is becoming a sizeable project and I'm
already running into problems organizing code and importing packages.
I feel like the Python package system, in particular the...
|
by: ishay44 |
last post by:
Hello!
I try to build (using Visual 2005 and Excel 2007) the example described in the Microsoft Help and Support "How to automate Excel from MFC and Visual C++ 2005 or Visual C++ .NET to fill or...
|
by: geolemon |
last post by:
Import text wizard says:
I'm banging my head on this one, here's why:
I've been importing files using this process and data format, with success!
I created a temporary table in Access to...
|
by: IT Couple |
last post by:
Hi
I'm pretty new to SSIS and I wonder if you could help me.
I download HTML files (thounsands) as text files using SSIS and then using foreach loop I load each file into table text data type...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |