Transform a CSV file using the same file name

Hi Dmitry,

I have created a project to transform a CSV file, I can’t figure our how to create the output file with the same name as the input file?
Also how can the project pick up different file names from the same place?

I believe it involves using parameters but I’m not sure.
Can you help?

Thanks
Victor

Hi Victor,

check out this tutorial chapter: Tutorial - Parameters. The upper picture there shows how to use a parameter instead of a file name. Just use the same parameter for input and output files.

Not sure I understood you correctly, but if you’re talking about running the same project for many different files in a folder, then it can be done using iterations. In a nutshell it works as follows:

  1. Create a project (A) that transforms one CSV file which name is defined by a parameter.
  2. Create another project (B) that uses “File list” transformation to generate a list of files in particular folder.
  3. Add “Iterate” transformation to project B that will run project A for each line in the list, assigning file names to the parameter of project A.

See also example #1 in Tutorial - Iterations.

Thanks for that I’ll give it a go
Victor

Hi There,

I have created a filein and a fileout parameter, but I have to enter a file name, how can I use any file that is in that directory and output the transformed version with the same name to a different file?
Luckily there is only one file in the directory at a time.

As you can see from the screen shot I have just duplicated the file name manually, can I do this automatically?

Thanks
Victor

Use calculated parameters. See below.

calculated_filename.morph (755 Bytes)

Hi Dmitry,

Thanks for that, it works well. the input file and the output file share the same name.
The problem is that the File name will change whenever a new file is dropped into the FromCG directory.
I can’t seem to find the ‘File List’ transformation you referred to in a previous post?
The help screen says it exists but not where to find it.

Thanks
Victor

This transformation is a start transformation meaning that it creates a new table rather than modifies already loaded data. You can see start transformations when you click “Insert table” button (see below).

Excellent thanks.
I’m impressed with your speed of replies to my questions

1 Like