Rename txt file name in Pentaho - pentaho

I have a problem. I have created a few files txt in directory.
file1.txt
file2.txt
file3.txt
Next I writing name files to file txt: filenames.txt with step: Shell.
ls D:\test\prep\ > filename.txt
I have there all name files which are in directory. My filenames.txt looks like this:
file1.txt
file2.txt
file3.txt
Later I read the values from the file in step Text file input and value which I get I writing to step copy to result.
Next I use get rows from result and transformation_executor.
I would like get a new name file for each file with step get rows from result: instead file1.txt I want file.txt. I think that in transformation_executor I must have TABLE_INPUT with name with step get rows from result but I don't know what's next.
Any have idea?

You need to use below step/way, if you want to read a directory files based on another configuration file (which contain the directory files information).
Step-1:
Step-2:
Step-3:
You can found the all transformation/Job from HERE
Please let me know if its ok with you.

Related

How to print contents of file as well as filename in linux using some adhoc command

I have multiple files starting with DUMP_*.
Each file has data for a particular dump.
I want to print filename as well as contents of file in stdout
The expected output should be
FILENAME
ALL CONTENTS OF FILE
and so on
Closest thing I have tried is
cat $(ll DUMP_* | awk -F ' ' '{print $9}' ) | less
With this I am not able to figure out which content belongs to which file.
Also, I am reluctant to use a shell script, an adhoc command is preferred.
This answer is not fully in line with your expectations, but you see the link between a filename and its content even better:
Situation:
Prompt>cat DUMP_1
Info
More Info
Prompt>cat DUMP_2
Info
Solution:
Prompt>grep "" DUMP_*
DUMP_1:Info
DUMP_1:More Info
DUMP_2:Info

Add a header row to a bed file in Cygwin

I have a bed file of three columns, and I would like to add the following headers: (chr \t start \t stop). I tried using the following command
echo -e "chr\tstart\tstop" | cat - myfile.bed > /tmp/out && mv /tmp/out myfile.bed
But every time I run this I get the follwoing error: cat: myfile.bed: No such file or directory
Although I'm sure the file is in that directory with the same name.
What edits I can make to let this work? or if you know another way of adding a header to a tab delimited bed file, please suggest.

Removing files from a directory based on file names in another file

I have a directory which contains multiple file (~1000) with names in the form of ABC.txt, ABC.1.txt, ABC.2.txt, XYZ.txt, XYZ.1.txt and so on.. I want to consider these names based on the first index if we split them by .. For example then names will be read as ABC XYZ and so on.. Then I want to remove those files for which these first index does not exist in an other (reference file). Given the file names mentioned above, let's say my other (reference file) only contains 1 name and that is XYZ. So the files that will be kept in the directory will be XYZ.txt and XYZ.1.txt and everything else which does not have the exact prefix as XYZ will be removed. I said exact because it might happen that there will be a file with name XYZA.txt, so there should be an exact match in order to keep that file.
Can anybody help me with this. Thank you very much.
EDIT: One directory contains all the files: ABC.txt, ABC.1.txt, ABC.2.txt, XYZ.txt, XYZ.1.txt and the reference file is in another directory as file name reference.txt and is a one-column file containing other directory's file (prefix)names as ABC, XYZ, CDE etc..
try
for f in *.*;
do if grep -qF "${f%%.*}" file;
then echo "skip $f";
else echo "rm $f"; fi;
done
searches all files with a dot in file name, extract the prefix until the first dot, compare literally in the file with not to be deleted names, and echo the rm file command. Make sure your file with names doesn't have a dot, otherwise it will be removed as well.
if looks fine remove echo before rm.

While read loop and command with file output

I have run into an issue making a while loop (yes, I am new at this..).
I have a file $lines_to_find.txt, containing a list of names which I would like to find in another (large) file $file_to_search.fasta.
When the lines in lines_to_find.txt are found in file_to_search.fasta, the lines with search hits I would like to be printed to a new file: output_file.fasta.
So I have a command similar to grep, that takes the sequences (for that is whats in the large file), and prints them to a new file:
obigrep -D SEARCHWORD INPUTFILE.fasta > OUPUTFILE.fasta
Now I would like the searchword to be replaced with the file lines_to_find.txt, and each line should be read and matched to the file_to_search.fasta. Output should preferably be one file, containing the sequence-hits from all lines in file lines_to_find.txt.
I tried this:
while read line
do
obigrep -D '$line' file_to_search.fasta >> outputfile.fasta
done < lines_to_find.txt
But my outputfile just returns empty.
What am I doing wrong?
Am I just building the while read loop wrong?
Are there other ways to do it?
I'm open to all suggestions, and as I am new, please point out obvious begginer-flaws.

List All Files in a Directory using Dot Net Zip?

Is there anyway in Dot Net Zip that I can use to list all the names of files in a specific directory? For example, i can specify Directory1 and get File3 and File4 etc
ZipFile
-------
File1
File2
Directory1
File3
File4
Directory2
File5
File6
ZipFile object has only Entries, Entries Sorted, and Entries File Names...
Anyone?, Cheeso? :)
No, and yes. There is no EntriesInDirectory collection. However, it's a simple matter of string comparison to select entries that "belong" in a particular directory.
In LINQ it looks like this:
var selection = from e in zip.Entries
where e.FileName.StartsWith(directoryName)
select e;
In a for loop, it looks like this:
var list = new List<ZipEntry>();
foreach (var e in zip.Entries) {
if (e.FileName.StartsWith(directoryName)) {
list.Add(e);
}
}
EDIT
You may have to do conversions for case sensitivity. On Windows, case is not meaningful in file names.
Further Explanation: the zip format doesn't treat a directory entry in the zip file as a container. There is no container relationship between directory entries and file entries. The only way to tell if a file entry "belongs in" a particular directory is to examine the full name of the file entry. If the name of the entry starts with the name of the directory in question, then the entry is "in" the directory.