Re: How to parse data from an imported array
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Thu, 25 Aug 2005 11:14:08 +0800
This would be *very* messy to try in a query only.
You will need to write some VBA code to follow these steps:
1. Use TransferText to import the file into a temp table.
2. Write some code to OpenRecordset() into this table, and also into the
target table (to append to.)
3. Loop through the records in the source table.
4. At each record, use Split() to parse the field into an array at the
comma. (Assumes at least Access 2000.)
5. Loop through the array from Lbound to UBound, with an AddNew and Update
to create the individual records in the target table.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"warren50" <warren50@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4CB92171-24EC-4E41-AC11-91E0BC8D04AB@xxxxxxxxxxxxxxxx
>I have an Access database that imports a comma-delimited text file that has
>a
> field that contains a list of URLs that are comma seperated (the array).
> Example:
>
> stock_number,image-urls
> "1234","http://photos.store.com/dcm_3.jpg,http://photos.store.com/dcm_769.jpg"
> "1235","http://photos.store.com/dcm_6.jpg,http://photos.store.com/dcm_0134.jpg"
> "1236","http://photos.store.com/dcm_7.jpg"
>
> The [image-urls] field could have from 1 to 100 seperate URLs depending on
> how many photos were taken of the item. Once I import the data file I need
> to
> parse the URLs into another table with an individual record for each URL
> and
> the corresponding stock number that matches that URL. Example:
>
> stock_number|image-url
> 1234|http://photos.store.com/dcm_3.jpg
> 1234|http://photos.store.com/dcm_769.jpg
> 1235|http://photos.store.com/dcm_6.jpg
> 1235|http://photos.store.com/dcm_0134.jpg
> 1236|http://photos.store.com/dcm_7.jpg
>
> I then will export this table and use in an outside script that goes to
> the
> URL and downloads the photo renaming it to the stock number_1.jpg, _2.jpg
> etc... so that I have the photos with formatted in naming convention that
> is
> descriptive of the image.
>
> I can use Left([image-urls], InStr([image-urls], ",")-1) right now to get
> the 1st image, but I don't know how to move on through the array to et the
> remaining photos.
>
> I want to do this all in an Access query using SQL and built in functions
> if
> possible.
.
- Follow-Ups:
- Re: How to parse data from an imported array
- From: peregenem
- Re: How to parse data from an imported array
- Prev by Date: Re: help with a running balance...
- Next by Date: RE: Setting up query with multiple data
- Previous by thread: Help with creating query with multiple tables/queries
- Next by thread: Re: How to parse data from an imported array
- Index(es):
Relevant Pages
|