- Posts: 21
READ and WRITE adapters and filenames
- Andrew Wojciak
- Topic Author
- Offline
- User
Less
More
9 years 7 months ago #2364
by Andrew Wojciak
READ and WRITE adapters and filenames was created by Andrew Wojciak
In the READ adapter:
I am creating .fhd to import from Folder1 and export to Folder2.
Each day, in Folder1 is a file with a different name - time stamp. In the Filename [TextFileAdapter READ] I have tried both * and % as wildcards but are not working. Can I create .fhd which when scheduled to auto-run daily will pick-up any FORECASTyyyymmdd.txt file. Should FORECAST*.txt work or something else?
In the WRITE adapter, in Filename, I would like to have a code or something so .fhd exports data to a file with an name as the READ file but with a prefix FH, for example: If READ file is=>FORECAST20150331.txt so WRITE file should be=> FH_FORECAST20150331.txt
Let me know please.
Andrew W.
I am creating .fhd to import from Folder1 and export to Folder2.
Each day, in Folder1 is a file with a different name - time stamp. In the Filename [TextFileAdapter READ] I have tried both * and % as wildcards but are not working. Can I create .fhd which when scheduled to auto-run daily will pick-up any FORECASTyyyymmdd.txt file. Should FORECAST*.txt work or something else?
In the WRITE adapter, in Filename, I would like to have a code or something so .fhd exports data to a file with an name as the READ file but with a prefix FH, for example: If READ file is=>FORECAST20150331.txt so WRITE file should be=> FH_FORECAST20150331.txt
Let me know please.
Andrew W.
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Offline
- Admin
9 years 7 months ago - 9 years 7 months ago #2365
by FlowHeater-Team
Best wishes
Robert Stark
Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Replied by FlowHeater-Team on topic READ and WRITE adapters and filenames
Hi Andrew,
To support wildcards (e.g. C:\Temp\*.csv) you have to use the Batch Module option /ReadFileName
For example: FHBatch.exe /ReadFileName C:\Temp\*.csv adopt-csv-filename.csv
NOTE: All CSV file who match this condition are processed!
Here you find an example how it works: Automated batch CSV import into MS Access
To adopt the CSV filename into the Definition for further processing you need the help of the .NET Script Heater and the simple Script below.
The script returns just the CSV filename without the path. With the String Append Heater you have to add a prefix “FH_” to this result and afterward set this value to a FlowHeater Parameter by using the Set Parameter Heater . This Paramater (e.g. $FILENAME_WRITE$) you have to use in TextFile Adapter for the CSV output file name.
I’ve made a simple example for this, please have a look to the example adopt-csv-filename.zip
To support wildcards (e.g. C:\Temp\*.csv) you have to use the Batch Module option /ReadFileName
For example: FHBatch.exe /ReadFileName C:\Temp\*.csv adopt-csv-filename.csv
NOTE: All CSV file who match this condition are processed!
Here you find an example how it works: Automated batch CSV import into MS Access
To adopt the CSV filename into the Definition for further processing you need the help of the .NET Script Heater and the simple Script below.
Code:
public object DoWork()
{
// adopt the CSV file name from the READ Side!
TextFileAdapter adapter = (TextFileAdapter)AdapterRead;
// get file name without path
string filename = Path.GetFileName(adapter.Filename);
// return the file name
return filename;
}
The script returns just the CSV filename without the path. With the String Append Heater you have to add a prefix “FH_” to this result and afterward set this value to a FlowHeater Parameter by using the Set Parameter Heater . This Paramater (e.g. $FILENAME_WRITE$) you have to use in TextFile Adapter for the CSV output file name.
I’ve made a simple example for this, please have a look to the example adopt-csv-filename.zip
Best wishes
Robert Stark
Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Attachments:
Last edit: 9 years 7 months ago by FlowHeater-Team.
Please Log in or Create an account to join the conversation.
Time to create page: 0.264 seconds