473,796 Members | 2,864 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Text Files - Dev

Roy
I use a Access 2K application.I am trying to use Chuck
Grimsby(clsRead TextFile.txt)cl ass utility to read a text file and then
do a import of the same into my database.The question is how to call
these in a button event or any other method.

Thanks,
Roy

Nov 13 '05 #1
16 4811

Well, since I wrote that silly little bit of code, I suppose I should
be the one to answer it, but sadly, I'm not quite sure what you are
asking for here.

The class provides the method for _reading_ a file, but you'll have to
do the selecting of _which_ file to read outside of the class. You
can do that fairly easily with the code at
<http://www.mvps.org/access/api/api0001.htm>

After selecting the file to import, simply follow the code example
within the class starting where it says:
' sample useage:
'Sub ReadAFile(strFi leName)

through the line that reads:
'End Sub

If that doesn't answer your question(s), feel free to ask! (Ah, here,
in the newsgroup, not in email, unless you want to pay me....)

You may also want to search Google Groups for previous discussions on
the clsReadTextFile class.
On 29 Jul 2005 12:23:36 -0700, "Roy" <pr********@yah oo.com> wrote:
I use a Access 2K application.I am trying to use Chuck
Grimsby(clsRea dTextFile.txt)c lass utility to read a text file and then
do a import of the same into my database.The question is how to call
these in a button event or any other method.

--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Nov 13 '05 #2
Here is a more bare bones procedure for reading data from a textfile and
writing it to an Access table,
--------------------------------------------------
Sub GetAndParseText FileData()
Dim db As dao.Database, i As Integer, j As Integer
Dim k As Integer, m As Integer, n As Integer, p As Integer
Dim RS1 As dao.Recordset, RS2 As dao.Recordset
Dim SourceDoc As String, str1 As String

Set db = CurrentDb
Set RS1 = db.OpenRecordse t("tblDataPicku p")
SourceDoc = "U:\someDir\tes tFile.txt
Open SourceDoc For Input As #1
i = 0
Do While Not EOF(1)
Line Input #1, str1
RS1.AddNew
RS1(0) = str1
RS1.Update
RetVal = SysCmd(acSysCmd SetStatus, i)
i = i + 1
Loop
Close #1
RS1.MoveFirst

Set RS2 = db.OpenRecordse t("tblParsedDat a")
Do While Not RS1.EOF
str1 = RS2(0)
i = 1
j = 1
RS2.AddNew
For k = 0 To RS2.Fields.Coun t - 1
j = InStr(i, str1, "|")
m = Len(str1) - (Len(str1) - j)
p = m - i
str2 = Trim(Mid(str1, i, p))
RS2(k) = str2
i = j + 1
Next
j = Len(str1) - i - 1
str2 = Right(str1, j)
RS2(k) = str2 '--this is the last column in table
RS2.Update
RS1.MoveNext
RetVal = SysCmd(acSysCmd SetStatus, "Parsing " & n)
n = n + 1
Loop
RS1.Close
RS2.Close
End Sub
---------------------------------------------------

tblDataPickup only has one field - a memo field that will accept any
sized text line using the Line function. tblParsedData will have the
same number of columns as your delimited textfile. You pull the raw
data into tblDataPickup and then parse it into tblParsedData. This
example uses a pipe | as the delimeter. I have variable length fields.
If your fields all have the same length, then you are in luck - don't
have to calculate field length. I also use SycCmd to display a count of
records on the status Bar of Access (usually picking up 7000-10000
records). This should be generic enough for your use.

HTH
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3
Roy
Thanks to both of you.I tried with Rich's solution in my code.I used
two tables .The data was read into the first table .but it fails to
read into the parsed table ,with an error no current data.The str1
returns Null.

I am pasting a sample of my text file below,mine is a tab delimited
text file.

1000 NULL 33497 NULL
CitiDirect Platform and Business Systems inte
Application Services Incident/Outage caused
by software failure. Incident/Outage caused by software failure.
Int CIB - Cash
NULL
NULL New Citicard customers unable to access
ATM & Citidirect
Citiphone Brisbane, Australia received a complaint from a customer on
27 July 2001 at 15:30 AEST that the transaction was declined at ATM
with error message of Invalid Card. Attempt on Citidirect also failed.
Investigation on this incident did not start until the GTMS ticket was
received by the Country CitiDirect Support Team on 30 July 2001. The
cause of the incident is found to be in the BAFES system where there is
a limitation on the file size. The customer file in BAFES is defined
as an Indexed Sequential file. Stratus has a limitation on this file
type. It cannot exceed 2GB in size. Ausstralia's BAFES's customer
file size has exceeded this number.As a result, any new additions to
the customer file will fail. This may explain the missing customer
records for those newly added. There can be 2 possible solutions. One
is to removed any unwanted customer records (i.e. some house-keeping in
GRB) to reduce the file size. The alternative solution is to redefine
the file in BAFES to be an Indexed Relative file. In this case, there
will be no limitation onthe size for this file type.
Yek-Ling Chong
With joint effort from Singapore GRBS and BAFES support, a full
customer renewal was done last Saturday- 11 August 2001 (completed
around 8pm Sydney time). No downtime was reported.

Aug 12 2001 10:58PM Non-critical (Yellow) Closed
Fe Ganuelas
+612 822 51546 NULL
NULL NULL
NULL NULL
NULL NULL NULL
NULL
NULL NULL NULL
Jul 27 2001 3:30PM Aug 11 2001
8:00PM Not Implemented NULL
NULL NULL

NULL



(GMT+10:00) East Australian Standard Time NULL
NULL NULL
NULL
NULL NULL NULL
NULL NULL

NULL



NULL

1001 NULL NULL NULL
NULL
Market Data Services NULL
NULL
NULL NULL
NULL
NULL Equity users are unable to start Reuters
Plus application on PC - Mkt Data team
aware and investigating as of 8.00am this morning.



Roy Sherman
Firewall problem corrected as of 10:00 this morning.



Aug 6 2001 2:23PM Critical (Red) Closed
Alex Lucero
212-723-1400 NULL
NULL NULL
NULL NULL
NULL NULL NULL
NULL
NULL NULL NULL
Aug 6 2001 8:00AM Aug 6 2001
10:00AM Not Implemented NULL
NULL NULL

NULL



(GMT-05:00) Eastern Standard Time NULL
NULL NULL
NULL
NULL NULL NULL
NULL NULL

NULL



NULL

1002 NULL NULL NULL
NULL
Exchange Services NULL
NULL
NULL NULL
NULL
NULL Nasdaq is having streetwide problems
updating quotes as of 10:00
Nasdaq is currently investigating.



Roy Sherman
Nasdaq has resolved their quote update issue at 10:35



Aug 6 2001 2:40PM Critical (Red) Closed
Alex Lucero
212-723-1400 NULL
NULL NULL
NULL NULL
NULL NULL NULL
NULL
NULL NULL NULL
Aug 6 2001 10:00AM Aug 6 2001
10:35AM Not Implemented NULL
NULL NULL

NULL



(GMT-05:00) Eastern Standard Time NULL
NULL NULL
NULL
NULL NULL NULL
NULL NULL

NULL



NULL

Can you shed some more light on this?

Thanks,

Roy

Nov 13 '05 #4
Roy
Thanks for the reply.The problem i am having is when the code bombs
saying,it cannot identify the class created,clsRead TextFile.I am using
your code in a button event
DoCmd.OpenModul e "modImportAllTe xt", ReadAFile

modImportAllTex t contains all the code and the ReadAFile is a function
which is called.

Thanks,

Roy

Nov 13 '05 #5
On 1 Aug 2005 06:02:13 -0700, "Roy" <pr********@yah oo.com> wrote:
Thanks for the reply.The problem i am having is when the code bombs
saying,it cannot identify the class created,clsRead TextFile.I am using
your code in a button event
DoCmd.OpenModu le "modImportAllTe xt", ReadAFile
modImportAllTe xt contains all the code and the ReadAFile is a function
which is called.


The class needs to be a _class_ object, not a module.

Delete your existing module, as it'll just cause Access to be
confused.

Make sure the clsReadTextFile .txt file is in your "My Documents"
directory.

Open up the VBA editor. In the immediate window, type in (or better
yet, cut and paste) the following command:

Application.Loa dFromText _
acModule,"clsRe adTextFile", _
"clsReadTextFil e.txt"

You also cannot use the DoCmd.OpenModul e on the code. You need have
something in there like:

Call ReadAFile(strFi leToRead)

Where strFileToRead is a string containing the file name and path to
the file you want the class to process.
--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Nov 13 '05 #6
Roy
Rich at this line it bombs with an error,saying No current record.

Set RS2 = db.OpenRecordse t("tblParsedDat *a")
Do While Not RS1.EOF
str1 = RS2(0) ----This line

Nov 13 '05 #7
Roy
Rich at this line it bombs with an error,saying No current record.

Set RS2 = db.OpenRecordse t("tblParsedDat *a")
Do While Not RS1.EOF
str1 = RS2(0) ----This line

Nov 13 '05 #8
Roy
Chuck,
Obviously I am doing something wrong here.I imported your
clsReadTextFile .txt to the MyDocuments folder.I pasted the code
Application.Loa dFromText acModule,"clsRe adTextFile",
"clsReadTextFil e.txt"
,but it errors ,saying ,it cannot read the clsReadTextFile .txt .Can you
please detail the steps how to go about the whole thing,please.

The text file i need to use is EMSTestFeed.txt .

Where do i fit this in your code?How do i read your class from the VBA
module.

Thanks,

Roy

Nov 13 '05 #9
Roy
Chuck,
Obviously I am doing something wrong here.I imported your
clsReadTextFile .txt to the MyDocuments folder.I pasted the code
Application.Loa dFromText acModule,"clsRe adTextFile",
"clsReadTextFil e.txt"
,but it errors ,saying ,it cannot read the clsReadTextFile .txt .Can you
please detail the steps how to go about the whole thing,please.

The text file i need to use is EMSTestFeed.txt .

Where do i fit this in your code?How do i read your class from the VBA
module.

Thanks,

Roy

Nov 13 '05 #10

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

Similar topics

2
2804
by: dunnm | last post by:
This is probably a more appropriate location to post this question. I should have know that since I've found most of the other PHP/PDF information contained in this group. Here's my issue...I will from time to time receive 4 - 5 PDF files into a directory; I want to be able to schedule a task which will pick up these 4 - 5 PDFs, read through them and then generate 1 pdf. Creating PDFs in PHP is obviously fairly easy, however I haven't...
19
10381
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much text is available until I have read it... which seems to imply that multiple reads of the input stream will be inevitable. Now I can correctly find the number of characters available by: |
1
6762
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but listen up; Reports, the way I look at them, all present data downwards, in this way; TITLE data
50
5016
by: Michael Mair | last post by:
Cheerio, I would appreciate opinions on the following: Given the task to read a _complete_ text file into a string: What is the "best" way to do it? Handling the buffer is not the problem -- the character input is a different matter, at least if I want to remain within the bounds of the standard library.
40
4604
by: googler | last post by:
I'm trying to read from an input text file and print it out. I can do this by reading each character, but I want to implement it in a more efficient way. So I thought my program should read one line at a time and print it out. How can I do this? I wrote the code below but it's not correct since the fscanf reads one word (terminating in whitespace or newline) at a time, instead of reading the whole line. #include <stdio.h> void...
1
1954
by: Hutty | last post by:
I have a program that open text files and compares them, however, when reading files larger than 500kb the programs seems to bomb. I get re-directed to "page not found". Any idea how to get around this issue? Ultimate goal is to read text files as big as 50mb or more. I'm using the "input type=file " to upload file, and then using Streamreader to read the text. Thanks -- Hutty
2
11654
by: Eshban Bahadur | last post by:
Hello, I want to read (RTF) files in my VB.NET programme. How can i do it. I apply the same method of reading text files, but it does not save the formatting of text like (bold, italics, underline) etc. So , how can i make programme which allows me to read (RTF) Rich Text Format files or Microsoft WORD files in VB.NET through FILE HANDLING. Plz help me
6
5274
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
2
3233
by: Wes Peters | last post by:
Does anyone know of an article that deals with the subject of reading a structured text file using VBA code in Access? Thanks, Wes
7
3067
by: random guy | last post by:
Hi, I'm writing a program which creates an index of text files. For each file it processes, the program records the start and end positions (as returned by tellg()) of sections of interest, and then some time later uses these positions to read the interesting sections from the file.
0
9525
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
10221
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
10169
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
9050
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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
6785
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
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.