0

Basically what i want to do is that,

I have CSV file containing 10,000 rows that i want to insert into the database . When i start my transformation i want to start inserting in database after 4500 rows . So i want to skill number of rows that i specified .

How can i achieve that ? Any help would be great.

Image Description : I simply create a transformation that read data from csv and write to database . I do not know which step will help me to achieve this .

Note : I have attached my simple transformation I simply create a transformation that read data from csv and write to database . I do not know which step will help me to achieve this .

Abhishek
  • 21
  • 8

2 Answers2

0

I haven't found a step that count the rows processed, but you can use the "User Defined Java Class" step to count the row number and delete the first 4500 with a code like this:

// This will be the counter.
Long rowCount;

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
    if (first) {
        rowCount = 0l;
        first=false;
    }

    Object[] r = getRow();
    if (r == null) {
        setOutputDone();
        return false;
    }

    // Increment of the counter.
    rowCount++;

    // Check ouf the counter. Doesn't output the current row if it's less than 4501.
    if (rowCount>4500l) {
        Object[] outputRow = createOutputRow(r, data.outputRowMeta.size());
        // Adds the row count to a stream field.
        get(Fields.Out, "Count").setValue(outputRow, rowCount);
        putRow(data.outputRowMeta, outputRow);
    }

    return true;
}
jtoledo
  • 1
  • 3
0

I used following kettle file , that solved my problem . Thanks to @WorkingHard..and @jxc I used the Add Sequencer and Filter rows to achieve this

Abhishek
  • 21
  • 8