Author Topic: I need a script to remove xml markup out of a text file  (Read 4214 times)

stonecherub

  • Jr. Member
  • *
  • Posts: 94
  • Ask the expert
I need a script to remove xml markup out of a text file
« on: June 01, 2015, 04:12:44 AM »
I have lost control of my categories by inventing new ones on the fly as I have ingested images. Dumping my categories into the text generator gives me a file that is mostly xml markup.

Being a clever fellow, I could probably learn enough about scripting to write a macro to strip out the xml markup, but it would take me a week whereas I suspect that some of you folks here have enough experience to do the same thing in 5 minutes.

Has anybody already written a "stripout" script that would return to me a text file containing only the category names?

ubacher

  • Oldtimer
  • ****
  • Posts: 2379
Re: I need a script to remove xml markup out of a text file
« Reply #1 on: June 01, 2015, 07:32:58 AM »
What is it you try to achieve?
IM5 is great for rearranging categories (as long as they are not keywords! i.e. stored in each file)

Just create your wanted category tree and move existing categories into it. (I suggest hierarchical category structures
for ease of filtering.)

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: I need a script to remove xml markup out of a text file
« Reply #2 on: June 01, 2015, 09:08:03 AM »
I'm confused. What did you do, exactly?

Quote
I have lost control of my categories by inventing new ones on the fly as I have ingested images

Do you mean you have categories you no longer want? How many? Why not just delete them in the Category View?
What is it you want to achieve?

Quote
Dumping my categories into the text generator gives me a file that is mostly xml markup.

With Text Generator do you mean the Text Export module?
The text export can produce several formats, including CSV , JSON and XML.
If you see XML data in the output, you probably have selected the XMP format. Using the text export is the wrong way to attack your problem anyway.

I assume that you want to export your categories, somehow manually edit them?

WARNING: Before you do anything, please a) make a backup copy of your database so you can roll back if you make a mistake, and b) make sure you understand the problem and the tools available in IMatch which may help to solve the problem.

We need more info in order to help you. Start with explaining what the problem is (what means "lost control"), what you see in the Category View and wht you want to do about it.

stonecherub

  • Jr. Member
  • *
  • Posts: 94
  • Ask the expert
Re: I need a script to remove xml markup out of a text file
« Reply #3 on: June 01, 2015, 10:47:16 PM »
My categories describe features of the volcanic field where I am working. When I am assigning categories to images, sometimes I need to add a category or split one into two or three children. My external category list is out of date because I have added so many new ones as I worked. That's what I mean by "out of control."

I am trying to AVOID having to type a new category list by reading them off the category panel in IM5.

Somehow, I don't remember exactly, I got the attached "categories.txt"  which contains my category hierarchy hidden in mark-up lines and effectively useless to me.

I have just re-read the entire category section of the help file which provides no information on how to do this. I feel bad about wasting your time on something that, apparently, nobody else needs just to save myself from having to key-in a bunch of words. Sorry.

[attachment deleted by admin]

sinus

  • Global Moderator
  • *****
  • Posts: 4489
  • IMatch-User since 2001 (IMatch 3.6)
Re: I need a script to remove xml markup out of a text file
« Reply #4 on: June 01, 2015, 11:40:47 PM »
I am so sorry, but I am afraid, I (still) do not understand what you want to do.
Best wishes from Switzerland! :-)
Markus

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: I need a script to remove xml markup out of a text file
« Reply #5 on: June 02, 2015, 08:02:46 AM »
Why do you need an external category list? For which purpose? I don't understand what you want to do.

Quote
When I am assigning categories to images, sometimes I need to add a category or split one into two or three children.

IMatch has a large number of features to create categories, move them, rename them, copy them. You can easily copy and move files between categories. What you describe above is easy to do in the Category View. Just add the new categories, and then distribute the files using mouse drag & drop or Ctrl+X, Ctrl+V ..

Why do you need a external text file which lists your category in 'Lightroom keyword format' (this is how your sample file looks).


stonecherub

  • Jr. Member
  • *
  • Posts: 94
  • Ask the expert
Re: I need a script to remove xml markup out of a text file
« Reply #6 on: June 02, 2015, 11:44:17 PM »
Adding categories to IMatch is trivially simple, thank you for that. In a way, I am using categories in place of captions because it is so simple to add a new one when needed.

The database is in support of a website dealing with a volcanic field in Mexico. As I walk down the length of a lava flow (frozen liquid rock) my pictures show features created by that freezing process. Those features have names and the names are my categories.

Perhaps somebody has compiled a controlled vocabulary for basalt rock features that I could have imported into my categories but I doubt it. I'm relying on my experience, adding new categories with your insert algorithm.

I would like to have a clean list of my existing categories for writing purposes. For example, what features do I know are there but I have missed photographing.

I think that by now, I have spent more time trying to explain what I need than if I had just read my categories from IMatch and typed them into Excel.


Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: I need a script to remove xml markup out of a text file
« Reply #7 on: June 03, 2015, 12:46:56 AM »
The native category export format of IMatch 5 is an XML file. This makes it easy to process the data, if there ever will be a need for that. If you export your categories, name the file nnn.xml and try to import it into XML.

But from your description I think you should use keywords instead of categories. This not only stores your assignments in the file itself, but also allows you to use the Thesaurus to build your keyword hierarchy. And the thesaurus can export to plain text files, which you then can use in Excel.

If you have some experience with scripting, it is not complicated to write a text file from a script, allowing you to export the categories you want to export and exactly in the format you want to export them.

ubacher

  • Oldtimer
  • ****
  • Posts: 2379
Re: I need a script to remove xml markup out of a text file
« Reply #8 on: June 03, 2015, 05:15:58 PM »
There is a sample script called categories.bas - under System Scripts

In it is a routine DumpAll which writes the categories to the scripting Output window.
It is commented out. Just remove the leading ' and you got what you want.
(Copy/paste the output window)

stonecherub

  • Jr. Member
  • *
  • Posts: 94
  • Ask the expert
Re: I need a script to remove xml markup out of a text file
« Reply #9 on: June 03, 2015, 06:49:20 PM »
Problem SOLVED!

Thanks, Ubacher, I used categories.bas and got exactly what I wanted. This leads me to think that I am bad at explaining things. Also, I suffer from FFUS syndrome - Failure to Fully Understand the Software.