I need to enter regular expression in a file path name inside tfileinputdelimited
I have a file watcher that is looking inside a directory for new files to be added. I want the new files have similar word for example file 1 is called apple1.csv and the other file that will be added at another time is called apple2.csv I want a way in order to tell talend to extract the file that contains the word apple, regardless of whats before or after.
Right now I have:
twaitforfile -> tflowtoiterate -> tfileinputdelimited -> tmap -> tdboutput
I believe tfileinputdelimited should have a regular expression as right now I selected a specific file
For the twaitforfile component, in the File Mask field specify the following: "*apple*.csv". This should grab only the files that have the word apple in them.
To dynamically grab these files base on their file names through tfileinputdelimited, you can use the FILENAME global parameter of the twaitforfile to achieve this:
Related
So I created this program that loops though all the lnk files in its folder and inserts an environmental variable into both the shortcut's target path and icon path. The problem is some of these target icons have a comma in the name, so when I use .IconLocation the file path cuts off after the comma and assumes the rest of the string is the icon index. Hence my question is how do you use .IconLocation and have a comma in the file path without it cutting of the rest of the string after the comma?
I am using ElasticSearch and Grafana to create a aggregated logging solution. The exceptions are being pushed to ElasticSearch no problem. But the library that I am using pushes the full name, for example System.Net.Socket.SocketException. These make for extremely large labels that run into each other. Is there a way to use a transform to change the label to just the class name, i.e. SocketException?
You can use the "rename by regex" transform to rename a field. I have used several to strip out the unwanted text in some fields. For example, on one dashboard I have this field name where all I want to extract "instance01":
servername_SQLStatistics_mssql$instance01\sql_compilations/sec
So my first rename by regex matches ".*mssql$" and replaces with nothing. This strips out anything up to the start of "instance01".
Then I do a second rename by regex that matches "\sql_comp.*" and replaces with nothing.
I get a list of files using the System.IO Directory thusly:
var srcFiles = Directory.GetFiles(remotePath);
I also have a comma separated list of strings, each of which I want to check for NON-existence in the names of the above files. For example:
string[] filterOn = EndPoint.FileNameDoesNotContainFilter.Split(',').ToArray();
gives me the following array:
filterOn contains ["GoodFile", "EvenBetterFile"]
Now, the files without either of the two strings would replace all the files currently in the srcFiles list above (or a new list, if that makes more sense). I am trying to do this with LINQ, but can't quite get there. How is it done?
EDIT: The answer from #dvo gives me the correct files, however, sometimes the filter strings are contained in the remotePath passed in.
A typical path/file: C:\TEMP\APPS\AMS\Services\sc0189v\APPS\GoodFile\test.txt.
As you can see, "GoodFile" is in the path, but not the filename. Yet this file should be rejected. I suppose I'm looking for something in System.IO.Directory that might help. Not sure, really.
Try this:
var noMatch = srcFiles.Where(file => !filterOn.Any(filter => file.ToUpperInvariant().Contains(filter.ToUpperInvariant()))).ToList();
This will create a new list where the file name does not contain any filter. This ignores case by converting both the file name and filter to uppercase. You can store the results in the same list if you replace noMatch with srcFiles. You can make it case sensitive if you remove .ToUpperInvariant() from both parts of the Any clause. You can capture the filter matches by removing the ! from the Where clause.
Hope this helps!
I have HTML input I am supposed to extract 2 Strings of, build a document title string of type <string 1> / <string 2, create a PDF from the source on the users mac desktop and name it as described.
I do know that a slash in a document name is not such a brilliant idea but this is what I am asked to do.
Problem is: the forward slash is interpreted as a folder on the mac and not as part of the documents name which means QPainter fails to print to PDF because it interpretes string1 / being a folder that doesn't exist.
BTW when omitting the / my code is working fine.
How am I supposed to escape the /?
Here's the string building logic:
QString docTitle;
docTitle.append(string1);
docTitle.append(" / ");
docTitle.append(string2);
On OS X, the name of a file at the level of the APIs is different from the display name that is shown to the user in the Finder, open and save panels, etc.
At the level of the APIs, file names simply can't contain slashes. They are reserved for separating names within a path. There's no form of escaping or quoting to allow it.
However, you can create a file whose name will be displayed with a slash in the UI.
Basically, the slash (/) and colon (:) characters swap roles. The display names of files can't include a colon, because it's reserved. (This is a holdover of the old HFS file system used in Classic Mac OS.) So, one aspect of the conversion from names-in-the-APIs to display names is to convert from colons to slashes. Thus, if you want a file whose display name has a slash, you actually use a colon.
A file whose name as per the APIs is "Important legal document 06:13:2015.pdf" will be displayed in the UI as "Important legal document 06/13/2015.pdf". Likewise, if a user names a file in a save dialog or in the Finder as "Important legal document 06/13/2015.pdf", it will end up with a name which, when observed via the APIs, will be "Important legal document 06:13:2015.pdf".
N2CMS uses standard .net enums to define options for editable drop down lists.
My drop down options need to include spaces, but of course you can't have a space in an enum item name.
I had hoped there would be some sort of attribute I could apply to define the text for the options. But I can't see anything anywhere that seems to do it.
I managed to work out how to do it in the end (by reading the N2 source). You use global resource files.
In particular, the code in EditableEnumAttribute calls HttpContext.GetGlobalResourceObject (by calling Utility.GetGlobalResourceString) for each item in the enum.
So to have enum names with spaces (and other special characters) in them, you add a global resource file that matches the name of the enum, with an entry for each enum item that needs special characters.
The first thing you need to do is add an App_GlobalResources folder to the top level of your project. This is vital, as if you use VS.NET to create resource files elsewhere they don't get created as global ones.
Next create a resource file in App_GlobalResources that matches the name of the enum. It needs to match just the short name of the enum, not the full namespace prefixed name.
Now create an entry in the resource file for each enum item, with the enum item name in the Name column and the name including the special characters in the Value column. You don't need to add an entry for every enum item, only for the ones with special characters (though it would probably make sense to add them all).