Clearing a file after reading with SSIS - sql-server

Is there any built in way to read a file with SSIS and after reading it clearing the file of all content?

Use a File System Task in the Control Flow to either delete or move the file. If you want an empty file, then you can recreate the file with another File System Task after you have deleted it.
My team generally relies on moving files to archive folders after we process a file. The archive folder is compressed whereas the working folder is uncompressed. We setup a process with our Data Center IT to archive the files in the folders to tape on a regular schedule. This gives us full freedom to retrieve any raw files we have processed while getting them off the SAN without requiring department resources.

What we do is create a template file (that just has headers) and then copy it to a file of the name we want to use for processing.

Related

Moving file to another directory in ABAP

I have got a service running in a specific directory in 5-second-intervals which is picking up an XML file created in that directory sending it for some necessary authorization checks to another client and then requesting a response file.
My issue is that my Z_PROGRAM creating the XML file might take longer than 5 seconds as a result of the file's size. Therefore creating the file in that specific directory is not preferable. I thought about creating a new folder in that directory called "temporary" and creating the file inside that folder, then once I'm done with it, moving it back outside for the service to pick it up.
Is there any way to move files from one directory to another via ABAP code only?
Copying the file manually is not an option since the problem that I have during file creation still persists. I need 2 alternatives, one used for local directories and one for application server directories. Any ideas?
Generally, we create another empty file for completed files after the file creation process ends. Third parties must be firstly checked empty file is there. Example:
data file.csv
data file.ok
If you already completed your integration and it is not easy to make any change with third parties, I prefer using OS level file moving commands. Sample document here. You can use mv for Linux server and move for Windows. If your file is big, you will get same problem with OPEN DATASET concept. We have ARCHIVFILE_SERVER_TO_SERVER FM for moving files but it is also using OPEN DATASET.
there is no explicit move command in ABAP code that move or copy files between directories in application server.
there is two tips can be helpfull in your case. if you are writing big file you may seperate the logic behind collecting data and writing file. I would say don't execute transfer data inside your loop. instead collect you data into an internal table once you're done, loop over this internal table and write direclty strings without any delay you should be able to write a big files upp to several hundred of MB under 1 sec.
next tips is to not modify your program, or if you are using function modules to construct xml is, write to a temp directory after finishing, then have another program open you file on source directory by read dataset and directly write data to the new directory again just strings without interruptions.
you should be ok if you just write strings.
You can simply use System Call Commands to perform actions in Application Directory.
CALL 'SYSTEM'
ID 'COMMAND'
FIELD 'mv /usr/sap/temporary/File.xml
/usr/sap/final/file.xml'

Drive File Stream altering my file names to add (1) at the end of their names

I am writing a program using WinForms in C# which monitors my drive file stream files, and copies the files to a local directory, where the files can then be run locally off of the computer.
My issue I am having is that when I alter or replace the files in the drive file stream either through the desktop app or the browser, it will rename some files to add an additional (1) at the end of the name. This then messes with the files when I need to run them from the local directory on my computer, as it cannot locate these specific files anymore.
Does anyone have a solution for this? Thanks.

KDevelop: Hide backup files

I am using KDevelop 4.3.1 with Debian Wheezy.
My problem is, that for every file in my project directory KDevelop seems to create a backup file with the same name, ending with a tilde. This makes the project directorys look really unclear.
My question is if there is an option to hide these backup files (e.g. all files ending with a ~) in KDevelop? Meaning in the sidebar list of project files.
The backup files are created on save by the text editor component "Kate Part". To get rid of the *~ files, you have two options.
First, open the editor settings dialog through Settings > Configure Editor and then choose the Open/Save item, and then the Advanced tab.
Disable backups
To disable backups entirely, remove the checkbox for [ ] Local files.
Hide the backup files
To hide backups, just add the Prefix: ., so that every backup file is a hidden file. A backup file is then named e.g. .MyFile.cpp~.
The idea behind the backup files is to have the old version around in case the saved file is corrupted for whatever reason (system crash, file system error, ...?). In practice, you most probably do not need backups at all for the following reason:
When saving files, Kate uses the class KSaveFile (in Qt5 available as QSaveFile). In short, to avoid data loss, KSaveFile saves the file to a temporary file in the same directory as the target file, and on successful write finally moves the temporary file to the target filename.
In other words, saving files is pretty save and in theory should always work due to the atomic rename thanks to KSaveFile.
So the only use case for backup files are that you changed and saved a file by accident. In this case, the backup file still contains the old data provided you did not save twice.
Even more so: If you use a version control system (git, svn, ...), the usefulness of having backups is close to zero. That's also the reason why backups are disabled entirely in newer versions of the editor component.
If you use this filter (in the top of the file list):
[A-Z]*[A-Z]
You may only see files starting and ending with a letter so no hidden files (starting with a '.') and no backup files (ending with a '~') will be shown.
Be careful as any other file not starting or ending with a letter will also be hidden

Need to write a batch file job

I need to write a batch job file to keep two folder in sync.
Inputs : Source and Destination folder names.
senario :
If the destination folder/subfolder is not found – create and proceed
If the files are already present in both the folders Compare and overwrite destination file if timestamp/size differs.
If the file not present in source and present in destination, delete the destination file.
kindly help me to write the batch job.
Thanks Vikram
A batch file written by a self-professed inexperienced user - even run periodically - is not a good replacement for a sync tool like rsync or dropbox or even the Briefcase built into Windows. Robocopy looks a good bet.

How do I clean up the temp files created by SharpZipLib

When I create a zip file using SharpZipLib I end up with .tmp files litering my hard drive. It occurs when I add files to an archive.
I'm not too concerned that it's happening, but I'd like to be able to get the file name so that I can remove the files once the archive is completed. How do I get the name of the .tmp file?
Are you closing the zip file you are creating? I use SharpZipLib for several apps and the .tmp file is always cleaned up automatically by the process once the newly generated zip file is closed and released by the process in every one of my apps.
I'm switching to a different library.

Resources