Solved

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

Posted on 2014-01-23
9
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 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