getting data from a text file

S

stujol

i have an access 2003 database. i have a text file which has loads of
instances of the below text. i want to be able to this data into a table so
for every instance of the word 'description', plance the description text
into the description field. Any help would be great... many thanks...

USER_ALARM NAME="_OAR ALARM"
user="PCSD_TEAM" time=1177594986/* "26-Apr-2007 14:43:06" */
{
DESCRIPTION="Operator Action Request"
ALARM_WORD="OAR"
MESSAGE="%P1 %P2"
CATEGORY="PROCESS"
SUMMARY_NO=7
DEFAULT_PARAM1="OAR/MSG1"
DEFAULT_PARAM2="OAR/MSG1"
WAVE_FILE=""
}
USER_ALARM NAME="_OAR_HORN"
user="PCSD_TEAM" time=1140541360/* "21-Feb-2006 17:02:40" */
{
DESCRIPTION="OAR Time Out Alarm"
ALARM_WORD="_OAR_HORN"
MESSAGE="OAR Time Out"
CATEGORY="PROCESS"
SUMMARY_NO=7
DEFAULT_PARAM1=""
DEFAULT_PARAM2=""
WAVE_FILE=""
}
 
K

KARL DEWEY

One way is to put data in table named [Text_Table] with field [Text_Data].
Create a query like this but continue to add the table to the design grid for
the other output fields.

SELECT
Replace(Mid([Text_Table].[Text_Data],InStr([Text_Table].[Text_Data],"NAME=")+7),'"','')
AS USER_ALARM,
Mid([Text_Table_1].[Text_Data],InStr([Text_Table_1].[Text_Data],"user=")+7,InStr([Text_Table_1].[Text_Data],"
time=")-10) AS [User],
Mid([Text_Table_1].[Text_Data],InStr([Text_Table_1].[Text_Data],"/*
")+4,InStr([Text_Table_1].[Text_Data],'"
*/')-InStr([Text_Table_1].[Text_Data],"/* ")-4) AS Alarm_Date
FROM Text_Table AS Text_Table_1, Text_Table
WHERE (((Text_Table_1.Auto)=[Text_Table].[Auto]+1));
 
D

Dorian

Your file is in the wrong format for automatically importing to Access.
You need to get your file into a format like a spreadsheet where you have
the field names going across and the value for each field below the heading.
Each field should either have a fixed width or you can have the fields
separated by commas or some other delimiter.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
K

KARL DEWEY

Another way I think will be easier is to open the file using Word.
Replace all =" with a tab -- =" with ^t
Replace all returns with tab -- ^p with ^t
Replace all { tab with return -- {^t with ^p

This puts all data for a record in a single line of text. Then it is
easier to parse.
 
K

KARL DEWEY

I errored here --
Replace all { tab with return -- {^t with ^p

it should read --
Replace all } tab with return -- }^t with ^p
 
M

Miladka Novotna

stujol said:
i have an access 2003 database. i have a text file which has loads of
instances of the below text. i want to be able to this data into a table
so
for every instance of the word 'description', plance the description text
into the description field. Any help would be great... many thanks...

USER_ALARM NAME="_OAR ALARM"
user="PCSD_TEAM" time=1177594986/* "26-Apr-2007 14:43:06" */
{
DESCRIPTION="Operator Action Request"
ALARM_WORD="OAR"
MESSAGE="%P1 %P2"
CATEGORY="PROCESS"
SUMMARY_NO=7
DEFAULT_PARAM1="OAR/MSG1"
DEFAULT_PARAM2="OAR/MSG1"
WAVE_FILE=""
}
USER_ALARM NAME="_OAR_HORN"
user="PCSD_TEAM" time=1140541360/* "21-Feb-2006 17:02:40" */
{
DESCRIPTION="OAR Time Out Alarm"
ALARM_WORD="_OAR_HORN"
MESSAGE="OAR Time Out"
CATEGORY="PROCESS"
SUMMARY_NO=7
DEFAULT_PARAM1=""
DEFAULT_PARAM2=""
WAVE_FILE=""
}


__________ Informace od ESET Smart Security, verze databaze 4628
(20091122) __________

Tuto zpravu proveril ESET Smart Security.

http://www.eset.cz



__________ Informace od ESET Smart Security, verze databaze 4628 (20091122) __________

Tuto zpravu proveril ESET Smart Security.

http://www.eset.cz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top