Populate columns with metadata

I am loading a .csv file that begins with metadata, then a table. I’m trying to take two fields from the metadata and populate two columns (for all rows).

This is what the .csv looks like;

Here is my workflow that successfully grabs the two fields of metadata, and transposes them into 1 row of two columns. I want to append those columns to the weather record columns, and repeat them for all the rows for that particular .csv though I’m stuck on how to do so. I’ve considered adding empty rows for just the two columns, though I can’t see a flow variable that would tell me how many rows of weather record data has been loaded. I’ve also explored Constant Value Column, though that has the same limitation.

I would try using a Table Row to Variable node after your node that has the table of metadata.

Then you can use two Constant Value nodes (one for each item of metadata) to append new columns containing that item of metadata to all the rows in your bigger table.

It would help if you posted a downloadable workflow and/or some example data.

3 Likes

That appears to get me a little farther along, though I’m having a hard time understanding exactly what is going on with the Constant Value Column. It seems to be putting out both columns, but only one row shows up in the output of the appender. Node 225 looks correct for one row, but there are thousands of other rows.

TestElecConsump.knwf (46.4 KB)

Here’s the .csv file (hmmm, no, it won’t let me. What format do people normally share .csv files in?)

One option is to save the csv file as a txt file (or some other compatible format) and upload it here.

Another option is to save the data with the workflow before uploading it here.

Another option is to put the csv file in the same folder workspace folder as the workflow, use the KNIME protocol for all your file paths, and

  1. package the entire workflow folder into a knar file and upload it here.
    or
  2. upload the workflow to your public KNIME Hub page and share the link
2 Likes

Ok, the text file seems the most understandable at the current time. I’ve had to abbreviate it as it was originally too big to upload.
faa_hourly-KPNE_20150101-20210130.txt (1.7 MB)

Just to clarify, the metadata you’re to include is the following?

Col0 Col1
Database: FAA_HOURLY
Id: KPNE

That is, you’d like each row to have a column that says “FAA_HOURLY” and another column that says “KPNE”?

Yes, thanks. And when I load a .csv from a different station, either or both could change for that set of data.

Check out this workflow and we’ll go from there.

3 Likes

Thank you! The behavior of this node is more clear now.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.