Anirudh
Anirudh

Reputation: 147

Using Pentaho Kettle, how can I convert a csv using commas to a csv with pipe delimiters?

I have a CSV input file with commas. I need to change the delimiter to pipe. Which step should I use in Pentaho kettle? Please do suggest.

Thanks!

Upvotes: 0

Views: 1779

Answers (3)

Otto
Otto

Reputation: 3294

You can achieve this easy: Add a javascript step after the load your csv step into a variable "foo" and add this code onto the js step:

var newFoo = replace(foo,",", "|");

now your cvs file is loaded in newFoo var with pipes.

Upvotes: 0

Brian.D.Myers
Brian.D.Myers

Reputation: 2518

If your goal is to output a pipe separated CSV file from data within a transform and you're already running Kettle, just use a Text File output step.

If the goal is to do something unusual with CSV data within the transform itself, you might look into the Concat Fields step.

If the goal is simply to take a CSV file and write out another CSV with different separators, use the solution @martinnovoty suggests.

Upvotes: 0

martinnovoty
martinnovoty

Reputation: 893

Do not use big gun when you try to shoot small target. Can use sed or awk. Or when you want to integrate with kettle, can use step to run shell script and within script use sed for example.

Upvotes: 1

Related Questions