Solved

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

Posted on 2014-01-23
9
279 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

829 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