Results 1 to 6 of 6

Thread: Generate field names from field contents?

  1. #1

    Default Generate field names from field contents?

    I have two fields, each of which contains a comma separated list. I want the values in the first list to become the field names that the second set of values are mapped to. Any ideas how to do that?

  2. #2
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    799

    Default

    Is it possible for you to share a couple of rows from each list?

    I'm pretty sure this is possible by using the Change Metadata node, but I need to see the data.

  3. #3
    Lavastorm Employee
    Join Date
    Apr 2014
    Location
    Boston, MA
    Posts
    279

    Default

    Hi, Daniel. It's been a while!

    I just did this with another customer two days ago. Not sure if it's the same thing you're after. See if it works. There are ways to consolidate the nodes (and improve performance), but I've broken it out into steps so it's easier to follow.

    But definitely post your data if you can. Stony can provide a more scalable example.
    Attached Files Attached Files

  4. #4

    Default

    Hey guys, thanks!

    Ryan, your example helped. No point posting a sample because my data was basically exactly like what your graph has after the "Join Inner" node.

    I tried hooking that right up to the Pivot - Data to Names node but that didn't work, I didn't understand how that node worked by grouping. Having seen your example I now know how to prep data for that node. Thanks!

  5. #5

    Default

    If this can be done better by the Change Metadata node, I'd be interested in that!

  6. #6
    Larry Tolleson ltolleson's Avatar
    Join Date
    Nov 2006
    Location
    Dallas-Fort Worth
    Posts
    189

    Default

    Hi Daniel,

    I like what Roger has done and I believe it is a scalable option. I use his method often. But in the spirit of being different I can show you another way this can be done.

    See the attached example I added to Roger's graph.

    Ok, let me explain what is happening in this graph.
    • First, the two datasets are concatenated together into a single field. Make sure the field name is the same for both datasets. I called the field "data".
    • Since the data already has a delimiter (commas) we can output this single field using the "Output Delimited" node. This node is doing a few tricky things, so let me explain.
      • First it is saving the file to the users temp directory. This is done by simply adding a filename without a path. I use this method when a file is only being used as temporary storage in a process.
      • This node is outputting just the data, which is the comma separated header and field values, and not the header you see in BRE. This is done by setting the "Field Names" parameter to "None".
      • Set the record and field delimiters both to "\n" which will write the entire record as you see it in BRE to the file. Since the data already have commas there is no need to add them on this output node.
    • Use the "Delimited File" node to read the data written by the previous step as a comma delimited file. This node must be clocked to the previous "Output Delimited" node so it will run only after the output node has completed.
      • Set the "File" parameter to the name used in the "Output Delimited" node.
      • Set the "Field Delimiter" parameter to a comma ",".
      • Set the "Record Delimiter" parameter to a new line "\n".
    Whether or not you use this technique for this application, you will have it in your back pocket for future uses.

    Thanks,
    Larry
    Attached Files Attached Files
    Last edited by ltolleson; 04-13-2016 at 04:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •