[SOLVED] How to add column names from a database table to a headerless text file

gvanvuurengvanvuuren MemberPosts:8Contributor II
edited September 2019 inHelp
I've got a standard csv text file, but without headers, which I want to write to an existing database schema. So first I load both the csv file and the database table into RM. Then I need to extract the column names from the existing database table. Then I need to rename the default column names assigned by RM to the loaded csv file by using the extracted column names from the database. And only then can I write the modified csv file back to the database.

The problem is that I cannot seem to join the db column names with the headerless csv columns. I've tried all the operators I could think of, but it doesn't seem possible to extract the db table's meta information into a seperate row in order to prepend the row to the csv file.

I'm sure such a simple ETL task shouldn't be a problem for RM. So I'd appreciate it if someone could point me in the right direction. Is there a way to extract meta-information from a table?

Thanks
Gideon

Answers

  • MariusHelfMariusHelf RapidMiner Certified Expert, MemberPosts:1,869Unicorn
    Hey, I'm sorry, it's not that easy. You need some macro magic and a loop. Please see the attached process for details. In your setting, instead of Generate Data you would read the CSV file.

    Maybe you can do the job also with some clever Transposings and Joins.

    Best, Marius
  • gvanvuurengvanvuuren MemberPosts:8Contributor II
    Hi Marius,

    thanks. I appreciate the effort. Could you please re-attach the process? I cannot see it.

    But I think what's missing is an operator that appends rows to a reference table based on the column indices (and types) of the reference table, instead of expecting column names to match. I've been meaning to try my hand at writing an operator, so maybe this is my opportunity;)

    Best
    Gideon
  • MariusHelfMariusHelf RapidMiner Certified Expert, MemberPosts:1,869Unicorn
    Well, I can't see it neither. Probably someone ::) forgot to insert the process. Here you go:


























    <运营商激活= " true "类= compatibi“循环”lity="5.3.000" expanded="true" height="76" name="Loop" width="90" x="313" y="120">














    <运营商激活= " true " class = "重命名" compatibility="5.3.000" expanded="true" height="76" name="Rename" width="90" x="313" y="30">





























  • gvanvuurengvanvuuren MemberPosts:8Contributor II
    I still haven't got it working quite yet, but I got the idea, thanks!

    The operators "Extract Macro", "Set Macro", "Loop Attributes", and "Rename" will do the trick.
Sign InorRegisterto comment.