View Full Version : Macros - Parsing a set of records.


weavinc
02-05-2009, 04:39 AM
I have one field in my table which contains records of html code (by that i mean multiple lines of html code that are treated as one record). My goal is to remove html from the records leaving behind only specially marked tags (tags that begin with "<-- Y2" and end with "-->"). The problem is the content of the special tags varies, and there is an unknown number of special tags in each record. i have to perform this task on all the records in the field and thus i need to automate this process.

I suspect regular expression will have to be used, but I am uncertain with how to achieve this in Access. I've also thought about exporting each record as an txt file (to use a program like python or perl to do the parsing for me) but i have no knowledge of how to do this.

dkinley
02-05-2009, 06:45 AM
I know of no macro that can do this; however as a starting point you might look at the help files at the functions Instr() and/or Split().

I am not sure if you have more than one special tags in each field. If so I would probably start at analying Allen Browne's example (http://allenbrowne.com/func-10.html) of parsing words.

Either approach will require heavy coding and/or modification to meet your needs - however, it is a starting point.

If each field only has one instance of the special tag it could make life easier. One such version of the psuedo code might look like ...

1 - Locate first tag
2 - Note the position of the first tag
3 - Find the end of that tag
4 - Note the position of the end
5 - Copy the text between the two positions to a new field

Or something along those lines. Hope this helps.

-dK

weavinc
02-05-2009, 07:00 AM
I know of no macro that can do this; however as a starting point you might look at the help files at the functions Instr() and/or Split().

I am not sure if you have more than one special tags in each field. If so I would probably start at analying Allen Browne's example (http://allenbrowne.com/func-10.html) of parsing words.

Either approach will require heavy coding and/or modification to meet your needs - however, it is a starting point.

If each field only has one instance of the special tag it could make life easier. One such version of the psuedo code might look like ...

1 - Locate first tag
2 - Note the position of the first tag
3 - Find the end of that tag
4 - Note the position of the end
5 - Copy the text between the two positions to a new field

Or something along those lines. Hope this helps.

-dK
Would you happen to know any tutorials for loops and going through a series of records in a field?

dkinley
02-05-2009, 07:14 AM
No, I am sorry - I do not, but that is what a query does. If you choose you could do this in a query using the Jet, SQL, DAO, or ADO to fetch the records.

The problem is regardless of the fetch method, you will still need a function that will go through the field of interest to parse it out for you - that's where Allen Browne's sample comes in, or, you can create your own function from scratch to try it. In this respect I stand on the opinion that once you get the function working for one record - then you can work on how to apply it to go through all of the records.

I know this isn't what you wanted - but it's all I have. It will take some time to go through the process of understanding and decoding Allen Browne's sample should provide a light-year leap as a guide.

There are other samples out there - you will have to do searches with the keywords "parse strings". I don't know if there is one there to specifically meet your needs - I was just providing starting points.

-dK

Mike375
02-05-2009, 07:35 AM
Go here

http://www.access-programmers.co.uk/forums/showthread.php?t=165246

as he has posted the contents of the field