Solved

Store the words in a .txt file in a table...

Posted on 2014-01-23
9
278 Views
Last Modified: 2014-01-23
test.txt contails some text in multiple lines. There is alos some occassional blank lines in it.

Question: How to store the words in it in a table in Access.

A blank space(s) separates the words.

Thank you
0
Comment
Question by:Mike Eghtebas
  • 4
  • 3
  • 2
9 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39803910
have you tried importing the text file?

External Data > select Text file from Import group
follow the wizard

if you want to do this using automation, you need to create an import specification.
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 39803936
re> have you tried importing the text file?

The lines in the text file are sentenses. These sentenses need to be disected (maybe using split function/method). The array produced needs to be cycled and its content (the words) then could be entered in the table.

Or there maybe a better way to do this. I am a bit rusty doing the above I thought I ask for some assitance.

Thanks,

Mike
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 39803971
If there is some way you can get the words into cells of a table, then you can work with the table as a data source for import into an Access table.  See my old Code Sample 8 on this topic:

http://www.helenfeddema.com/Files/code8.zip
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 39803997
re:> If there is some way you can get the words into cells of a table

This is what I am trying to accomplish in this question. This is like a circular answere, lol.

Thanks,

Mike
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39804020
you can read the text file line by line and decide how you want to treat the read lines.

post the text file here and explain how you want it parsed/dissected
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 39804183
I am disappointed at myself for not being able to describe this easily so others could understand it. Here I am repeating my original questions with examples:

test.txt contails some text in multiple lines.
---- test.txt--------
Water  date 5/78
tomorrow  yesterday ...

Monday appointment
---- end of test.txt--------

Question: How to store the words in it in a table in Access.

-------------tWord in Access----------
ID       Word         <-- field names
-----    -------
1      Water  
2      date
3     5/78
4    tomorrow  
5    yesterday
6    ...
--------------- end of the table tWord----

Please let me know if this is not clear,

Regards,

Mike
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 400 total points
ID: 39804221
try this codes


Sub parseText()
Dim fName As String, j As Integer, sArr() As String, sLine As String
fName = CurrentProject.Path & "\test.txt"
Open fName For Input As #1
     Do Until EOF(1)
     Line Input #1, sLine
     If Len(sLine) > 0 Then
     sArr = Split(sLine, " ")
     For j = 0 To UBound(sArr)
          If Len(sArr(j)) > 0 Then
     
          CurrentDb.Execute "Insert into tWord(Word) values('" & sArr(j) & "')"
         
          End If
     Next
     End If
Loop
Close #1
End Sub
0
 
LVL 31

Assisted Solution

by:Helen_Feddema
Helen_Feddema earned 100 total points
ID: 39804312
In my post I was referring to a Word table.  Sometimes you can get text into a table using the Word Text to Table command.  Then, once it is in a Word table, it can be imported from the Word table into an Access table.

In this case, though, using the Split function with an array might be the best solution, as in the previous post.
0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 39805146
Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now