PC Review


Reply
Thread Tools Rate Thread

Data import into access

 
 
Zark3
Guest
Posts: n/a
 
      13th Feb 2006
Hey all,
Just out of curiosity, hoping someone might have a good starter for me
on this, I need to import data into Access from a text file that
unfortunately isn't in the standard layouts of Access. Question now is
of course, how do I import?

File layout:
---
Field1 Value1
Field2 Value2
; Value2 (contd.)
Field3 Value3
$
Field1 Value1
Field3 Value3
---
etc. etc.

In other words, I have a grand total of 422058 lines, in which records
are separated by a dollar sign, values continued on a next line (line
break in input) have line 2 (and/or 3 etc.) preceded by a semicolon,
and field names (single words) and their respective values are
separated by a space, separating the fields by a line break. Records
will have ten to fifteen fields, fields not filled in don't appear in
the file (so no dummy/empty data).

The big question of course, who can provide me with a starter on how to
approach this import? Should I manipulate the file externally to some
format that Access can read, or can I trick Access into reading this
somehow?

Any help is appreciated,
Thanks,
Chris

 
Reply With Quote
 
 
 
 
Douglas J Steele
Guest
Posts: n/a
 
      13th Feb 2006
You're going to have to use the VBA File Input routines to read that file
line by line, building the SQL for an INSERT INTO statement for each record.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Zark3" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey all,
> Just out of curiosity, hoping someone might have a good starter for me
> on this, I need to import data into Access from a text file that
> unfortunately isn't in the standard layouts of Access. Question now is
> of course, how do I import?
>
> File layout:
> ---
> Field1 Value1
> Field2 Value2
> ; Value2 (contd.)
> Field3 Value3
> $
> Field1 Value1
> Field3 Value3
> ---
> etc. etc.
>
> In other words, I have a grand total of 422058 lines, in which records
> are separated by a dollar sign, values continued on a next line (line
> break in input) have line 2 (and/or 3 etc.) preceded by a semicolon,
> and field names (single words) and their respective values are
> separated by a space, separating the fields by a line break. Records
> will have ten to fifteen fields, fields not filled in don't appear in
> the file (so no dummy/empty data).
>
> The big question of course, who can provide me with a starter on how to
> approach this import? Should I manipulate the file externally to some
> format that Access can read, or can I trick Access into reading this
> somehow?
>
> Any help is appreciated,
> Thanks,
> Chris
>



 
Reply With Quote
 
Zark3
Guest
Posts: n/a
 
      13th Feb 2006
Ouch! Sounds like an nested jumble of if and while-statements waiting
to happen?
something like this pseudocode?
---
while not found dollarsign
if(first part of inputline matches field name)
fieldstring += fieldname
valuestring += remainder
else if(first char of inputline == ";")
valuestring += inputline
sqlstring = "insert into table1 (" + fieldstring + ") values (" +
valuestring + ")"
[somehow execute sqlstring (?)]
loop
---

Am I on the right path here do you reckon?

Thanks for the tip,

Chris

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      13th Feb 2006
Yup, that's about it.

The "somehow execute sqlstring" would be CurrentDb.Execute sqlstring,
dbFailOnError (assuming you've got a reference set to DAO)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Zark3" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Ouch! Sounds like an nested jumble of if and while-statements waiting
> to happen?
> something like this pseudocode?
> ---
> while not found dollarsign
> if(first part of inputline matches field name)
> fieldstring += fieldname
> valuestring += remainder
> else if(first char of inputline == ";")
> valuestring += inputline
> sqlstring = "insert into table1 (" + fieldstring + ") values (" +
> valuestring + ")"
> [somehow execute sqlstring (?)]
> loop
> ---
>
> Am I on the right path here do you reckon?
>
> Thanks for the tip,
>
> Chris
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import new data and replace old data in Access table. TBui Microsoft Access External Data 4 29th May 2009 04:19 PM
Import new data and replace old data in Access table. TBui Microsoft Access External Data 0 29th May 2009 03:21 AM
Memo format field data problem - Data import from Access database AFSSkier Microsoft Excel Programming 0 29th Apr 2009 05:51 PM
import xml data into Access 2003 - deletes all data in file =?Utf-8?B?TGFycnlAVVNEQQ==?= Microsoft Access External Data 1 26th May 2006 07:18 PM
Import Data From Access to Excel - Return Modified Data To Access HVG Microsoft Access External Data 0 9th Dec 2005 08:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:32 AM.