Re: [OpenRefine] Manipulating WordPress Metadata

69 views
Skip to first unread message

Tom Morris

unread,
Apr 24, 2013, 11:12:58 PM4/24/13
to openr...@googlegroups.com
It's almost certainly doable, but it'd be a lot easier to give you specific advice with an example of the input data.  I'm not sure whether the "more than one row" refers to something in the input XML, the CSV, or ...?

Tom


On Wed, Apr 24, 2013 at 7:06 PM, Adam K <adamw...@gmail.com> wrote:
Hello!

I'm very new to Refine, and so pardon me if this is a really simple question.

I'm trying to do some manipulation of some Wordpress data to speed along a process I'd rather not have to do by hand. I have a bunch of custom posts that have associated metadata, which I've exported from WP as an XML file. From this, I'd like to format a CSV file that I can upload back into WordPress (by way of a plugin) in order to tell it to assign each post in to a custom category taxonomy based on some of the metadata (this wasn't done during original data entry, for reasons not worth going into here). It's also got to reupload all the metadata, since the plugin creates new posts, rather than editing the existing ones (I'll just dump the existing ones in the trash).

This'd be easy if it were not for the fact that each post is represented by more than one row of data. There's a master row for the post that contains most of it, and then beneath that, there's a row for each custom field in the metadata. What I'd like to do is create columns for each metadata key, and then bring the value of that key for each post up from the several rows beneath the master row and into a column in the master row.

Hopefully that's clear.

I'd be glad for any thoughts or assistance. It's not a ton of data, but it's more than I really want to do by hand.

Thanks!
Adam

--
You received this message because you are subscribed to the Google Groups "Open Refine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openrefine+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Adam K

unread,
Apr 25, 2013, 1:09:40 AM4/25/13
to openr...@googlegroups.com
Thanks Tom. I'm attaching the XML here.

It seems like this...

https://code.google.com/p/google-refine/source/detail?r=2356

..should do what I want it to, but it's not behaving. It's only working on the first record. I'm not sure if it's the right thing, or of I'm misunderstanding its purpose.

To re-illustrate what I'd like to do:

For each actual record, there's a row with a non-null item - title. Directly beneath it, there are seven rows with null item-title values which are actually associated with the record above, but instead of being columns in the same row, they're key/value pairs where the key is in column item - wp:postmeta - wp:meta_key and the value is in column  item - wp:postmeta - wp:meta_value. What I'd like to do is create columns for each meta_key, and in each row with an item - title, include the meta_value as the value of the cell in the appropriate meta_key column. Essentially, flattening each record into one row. The meta_keys should be consistent throughout the file. It's OK if some of the meta_values are blank.

Hopefully that's an unambiguous description of what I'm trying to do.

Thanks again for any thoughts!! Even having to figure out how to do it in Refine is better than having to do the data entry by hand, and hopefully at the end I'll be smarter about how Refine works. :)
prime-resource-export.xml

Tom Morris

unread,
Apr 26, 2013, 6:15:41 PM4/26/13
to openr...@googlegroups.com
There's something weird going on, but I'm not exactly sure what.  We'll need to take a closer look at it.  Can you please file a bug report on Github so that it doesn't get lost?  If I get a chance I'll try to take a look this weekend.

Tom


Adam Kuglin

unread,
Apr 26, 2013, 6:19:10 PM4/26/13
to openr...@googlegroups.com
I sure can. You're thinking the Key/Value Columnize function should, ostensibly, be doing what I'm trying to do? Just so I know what to put in the ticket.

You received this message because you are subscribed to a topic in the Google Groups "Open Refine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openrefine/t88PE-q1kVM/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to openrefine+...@googlegroups.com.

Tom Morris

unread,
Apr 26, 2013, 6:40:59 PM4/26/13
to openr...@googlegroups.com
On Fri, Apr 26, 2013 at 6:19 PM, Adam Kuglin <adamw...@gmail.com> wrote:
I sure can. You're thinking the Key/Value Columnize function should, ostensibly, be doing what I'm trying to do? Just so I know what to put in the ticket.

Yes, that's the intention.  There's are secondary issues with a large number of blank rows getting created by the XML importer and with the ordering of columns not being the very good, but even after I deleted all the blank rows and moved the postID column to the beginning (so that it could be used to group records together), the key/value transpose still didn't work the way it should.  I fixed some some another problem in this area, but it looks like there's more work to be done.

Tom
Reply all
Reply to author
Forward
0 new messages