Why are my flow variables not showing up in a node?

#1

Just getting started with Knime (mainly use Tableau Prep but I need something with more functionality). I’ve downloaded several sample workflows that address this issue, but I’m unable to replicate it.

My use case is I have an input file that has X number of rows. For every 999 rows in the input file I need to create a separate output file with one synthetic row that summarizes the 999 other rows.

I was able to do most of this using brute force but now I’m trying the looping process. I’m able to get the loops to work but I can’t seem to get a dynamic file name to work.

I’m use the create file name node, and then storing the current iteration in the file name flow variable but when I connect that to CSV writer I do not see the output flow variable name as an option.

This seems to work for all of the sample flows I see so I must be doing something incorrectlyJournal Creation 2.knwf (12.7 KB)

0 Likes

#2

I tend to just use the Java snippet node to build the string for variable filenames

0 Likes

#3

I tried that below. I suppose my question is pretty basic.

My flow is File Reader - Chunk Loop Start - Java Edit Variable Simpe - CSV Writer - Variable Loop end (this flow doesn’t create the summary row per file yet).

I was able to get the variable from the java step into the csv writer flow variables but it’s not creating the files now.

I think I’m missing some basic fundamentals here. Any help is appreciated.Journal Creation 1.knwf (12.9 KB)

0 Likes

#4

HI there @ssimpson,

welcome to KNIME Community!

I have checked your workflows and thing missing is connection between Chunk Loop Start and CSV Writer node. Without data connection (which “transfers” data from one node to another) this won’t work :wink:

ForumExample

Try it out and if any questions feel free to ask.

Br,
Ivan

2 Likes

#5

@ipazin Thank you I appreciate it. I’ve now learned the difference between data nodes and variable nodes. You definitely fixed my first issue, but now I’m having difficulties meeting all of my requirements.

Requirements: Split a file into many separate files, each having 999 rows of the original file.

  1. Read in a file of variable length in 999 row increments (File Reader + Chunk Loop)
  2. Build a summary row and add it to the 999 making a 1000 row file below are columns and the values i want
    a. Line description - Should be a variable (similar to the one i have for the file name)
    b. 5 columns with hardcoded values
    c. Each of the 999 rows have an amount field, i want this to be the sum of the 999 amounts x -1
    d. More hardcoded values
  3. Name the 1000 row file and write it somewhere.

The part that I’m struggling with is how to do I create a synthetic row, I was able to do it with table creator but that has no inputs so I can’t connect it to my loop. I’m able to sum the amounts of the 999 records using group by but how do I place that in a column of my synthetic row?

Attached is my workflow, I was trying to add the rows with add empty rows and then fill them out but I can’t figure it out.

Any help is appreciated, liking Knime thus far just seems a bit overwhelming at first.Journal Creation 3.knwf (17.9 KB)

1 Like

#6

Hi there @ssimpson,

Not sure I understood every requirement but in general you want to add summary row. My approach would probably be to use Table Creator node to input hard-coded values (in case they really never change; in case they change maybe think about Configuration nodes). Then using Constant Value Column (if value in table) or Variable to Table Column (if value in flow variable) node add calculated values. Don’t see need for Add Empty Rows node.

Try it out and un-check reset option while exporting in order to check workflow :wink:

Br,
Ivan

0 Likes

#7

@ipazin

Thank you for your help thus far. Yes I was using the Table Creator to create the row. However, the issue I’m having is the Table Creator has no input step, so I cannot figure out how to put it inside the chunk loop.

IE if I have an input file with 9990 rows, I want to chunk it with 999 rows per chunk (10 files) and for each of those 10 files input a new created row with the Table creator.

I’ve tried putting the table creator outside the loop and joining it back with concatenate but I get ‘Input table must contain only String, Int, or Double’. I think this is because it’s not in the loop. I’ve googled that error and that seems to be the issue.

So how would I put the table creator within the loop? I do not see examples of that anywhere. Any help is appreciated.

Journal Creation 3.knwf (20.0 KB)

0 Likes