473,378 Members | 1,439 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,378 software developers and data experts.

Searching for files and extracting contents

Hi all,
I don't know if this is do-able but you never know until you ask. A
situation at work has arisen where I have to trawl through over 500 text
files, copy the contents and then paste them into an Excel sheet where it is
analysed. Would it be possible to copy the files, paste them into a
'reserved' directory and get Access to import the contents of all the file
in one go? The first line and last line of these text files would need to be
ignored. Other than that, the contents of each file is laid out in exactly
the same format and will not change.

Any help on this would be great,

Many thanks,

Mark
Nov 13 '05 #1
2 1513
I have found some code which I am trying to use but can't get it to work.
Can anyone tell me where I am going wrong?

Private Sub Command0_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\")
strfile = Dir("rec*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportFixed, "Standard Output", "Table1",
"C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile
strfile = Dir
Loop

End Sub

Thanks all,
Mark

"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:GO7Fc.30$%A3.10@newsfe5-win...
Hi all,
I don't know if this is do-able but you never know until you ask. A
situation at work has arisen where I have to trawl through over 500 text
files, copy the contents and then paste them into an Excel sheet where it is analysed. Would it be possible to copy the files, paste them into a
'reserved' directory and get Access to import the contents of all the file
in one go? The first line and last line of these text files would need to be ignored. Other than that, the contents of each file is laid out in exactly
the same format and will not change.

Any help on this would be great,

Many thanks,

Mark

Nov 13 '05 #2
"Mark Reed" <ma*********@ntlworld.com> wrote in message news:<GO7Fc.30$%A3.10@newsfe5-win>...
Hi all,
I don't know if this is do-able but you never know until you ask. A
situation at work has arisen where I have to trawl through over 500 text
files, copy the contents and then paste them into an Excel sheet where it is
analysed. Would it be possible to copy the files, paste them into a
'reserved' directory and get Access to import the contents of all the file
in one go? The first line and last line of these text files would need to be
ignored. Other than that, the contents of each file is laid out in exactly
the same format and will not change.

Any help on this would be great,

Many thanks,

Mark


As you noted, use Dir() to loop through the contents of the directory,
FileCopy to copy the file to a specific location...
If the first line and last line of the text files are easily
identifiable, you could delete those records with a query. Otherwise,
you'll have to open the file, read the contents a line at a time and
process them that way.
Nov 13 '05 #3

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

Similar topics

2
by: John | last post by:
Hi everyone ! This is a first time I post a message here. If I post my message in a wrong group. Please ignore it. I am trying to build a website which allows users (can be thousands of...
1
by: Derek Mortimer | last post by:
This is my first attempt to join a user group. I run an iMac and have recently upgraded to OSX, OfficeX, after years of problems. I am having difficulties with Find, or maybe do not understand its...
1
by: Aladdin | last post by:
I am using the java.util.zip package to create zip files. I can create a new archive and add files to it without any trouble. But if I already have a zip file created, how do I add a new file to...
2
by: Greg Lindstrom | last post by:
I've been zipping up files for months with zipfile, but today I was asked to extract the contents of a zip file and was sure there would be an "extract" method...but there's not one that I can...
2
by: Avi | last post by:
hi, Can anyone tell me what the problem is and how to solve it The following piece of code resides on an asp page on the server and is used to download files from the server to the machine...
4
by: Qwert | last post by:
Hello, is there a way to combine multiple files into 1 file with VB.NET? Example: Dim MyList As New ArrayList() MyList.Add("File1.txt") MyList.Add("File2.doc") Pack(MyList ,...
2
by: Chris Murphy via DotNetMonster.com | last post by:
Hey all, just wondering if anyone can point me in the right direction. I'm developing a solution that allows a user to store multiple text-based content (like code snippets, notes, documents etc.)...
6
by: reidarT | last post by:
I will develop a backup routine with local files (zipped) to an internet server via ftp. How do I zip files in Vb.net? reidarT
2
by: avik1612 | last post by:
hi, I have created a script in perl to extract n number of zip files to a particular destination after creating the folder of the zip file. It is extracting . But when the zip file has...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.