Solved

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

Posted on 2014-01-23
9
280 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 34

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 34

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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 34

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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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 34

Author Closing Comment

by:Mike Eghtebas
ID: 39805146
Thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

685 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