How can I save dataset values into one local folder path - sql

I need to save dataset values into a local folder path.
The dataset value I'm getting is another folder path. This has to be achieved in console application.
Suppose dataset value has c:\priyanka path after running the console application. The data has to be populated but to a new path like c:\Desktop. The data from one folder path has to be copied to another folder.
How we can I achieve this?

Related

pentaho spoon/pid: how to move files to folders with different name everytime?

I have new text files every month from where I extract the data and do some transformations. In the end of every month, I need to move these files to a folder with current date in name. Which means, the destination folder's name is different everytime.
I made a step before move files that creates a folder and its name is current date (exp: 2019-06-01, 2019-07-01), but then on move files step, I don't know how to specify the destination folder. Guess "wildcard" is only used for source...
Otherwise, on move files - Destination file - Move to folder, there is create folder option, thought it could be a solution but as on the screenshot, this section can't be modified. What is the reason?
Does anyone have an idea ?
Thanks for reading :))
You can utilize this approach for this task.
Basically you'll have to extract the date you want from each file before doing the transformations, and after all the transformations are done, you'll use the JOB step 'Move files', but instead of passing a fixed destination, you'll use variables in the path, much like this answer, but you don't need to create the folder before, you can just use the option on the 'Move files' step, so the folders are created at run time.
I have attached an example of this approach with some commentary in the KTR/KJB.
You can download here
Let me know if the link is working, this is my first time posting an external file in StackOverflow

Check if file exists in folder or not (SSIS, SDT 2015 and SQL 2016)

I need to load multiple files into a SQL table. I have three different formats, CSV, XLSX and XLS, but I will load one type of files at a time, no combination of different file types.
First, I will check in my source folder if the file exists or not. If it exists, load it to table and move to next file. The file checking and selection process must be dynamic. I don't want to hard code the file name in a variable. When the package starts, I need the filename variable to hold the very first file present in the folder each time when I run the package.
If the file is not found in the folder, send mail alert that file doesn't exist.
For example, if I have three files in my folder,
File1.csv
File2.csv
File3.csv
I run my package and I hard code the file name variable = File1.csv in the first run. My package gets executed successfully and loads the file1 to the table and archives it to the archive folder.
When next time for each loop runs, it looks for variable filename = File1, but it's already archived, so my package will not able to process file2 from the folder. How can I do this properly?
First use a script task to check if any file is present in the folder or not.Create an integer variable and set it to 1, if file is found and to 0 if file not found. Use expression and constraint in the precedence constraint.
http://www.techbrothersit.com/2013/07/ssis-how-to-check-if-file-exists-in.html
If evaluation expression is false,connect it to a mail task,else
connect to a for each loop task.
Please refer:https://www.simple-talk.com/sql/ssis/ssis-basics-introducing-the-foreach-loop-container/ or more details.
A trick in SSIS is to create a Foreach Loop.
Create a Variable containing the path where the file resides. Example User::filepath
Create another variable to save the actual file found on the Foreach loop, example User::filename
Add the Foreach Loop from the SSIS Toolbox.
On the Foreach Loop editor, on Collection left tab select in Enumerator - Foreach File Enumerator
Click Expressions and add one for Property Directory and select in the expression the #[User::filepath]
Enter on the Folder the value of the filepath variable (this will be overridden at execution from the Expression above, this is if you filepath is changed at runtime)
On file enter something like . or *.txt or whatever filter you want to apply to the folder.
On the Variable Mappings left tab select on the Variable column the User::filename variable, the Index column will default to 0.
Then put your logic inside the Foreach Loop box.
This will only execute your logic if a file is found. You can also use this to process multiple files if they exist on the folder.
Hope this helps.
The problem with Foreach Loop Container is it will not process any task within the container but will continue outside of it.
A solution is an expression on the constraint to the next task.
enter image description here
It will check the variable length used in the Foreach Loop Container. If a file isn't present, the expression will return 0 and FALSE.
LEN(#[User::filePath]) > 0 ? TRUE:FALSE
filePath = Foreach Lop Container variable
enter image description here

Excel VBA for opening listed files and saving to new listed location

I am very new to vba and want to build a code to function the below requirement.
There are multiple file names in listed in an excel sheet from a particular folder, these needs to be opened one by one -> delete column A -> rename with the name defined in the excel list -> save on new path after creating new directory if does'nt exist which is also defined in the file.
This is my sample datasample data
please assist
Open and close files: http://www.excel-easy.com/vba/examples/close-open.html
Delete a column: https://analysistabs.com/vba/delete-entire-column-excel-macro-example-code/
Create folder: https://www.techonthenet.com/excel/formulas/mkdir.php
Rename files: https://www.mrexcel.com/forum/excel-questions/586216-excel-visual-basic-applications-rename-existing-file.html
Move files: https://www.mrexcel.com/forum/excel-questions/637606-move-files-another-folder-visual-basic-applications.html
This should give you a good start, post your code if you get stuck.

Find file with specific text in folder

I am trying to loop through all the files in a folder and get the path of one that contains a specific part of text. The text is not always in the same position and the folder is a network folder.
What would be the fastest way to do this in a network folder that contains hundreds of files with more than 30Mb each?
The Dir() solution did not work as it says "Bad file name or number" (Error 52). I am referencing the network path as \\thisisthefolder\anotherfolder\

Creating a file with name given in code in LiveCode

I'm trying to build a program that gets users name at first. This user names are kept in a text file. After user logins, according to the user's name, I want user to be lead his/her specific informations. I figured out that I can only do it with a file that is created when he sign up for an account which I direct him with my sign up button in Livecode. While he/she create his account I want to create a specific file for his/her. Can you help me with it please?
PS: I don't want to do it with a database right now. I just want to learn how to create a file without a specific name like
put specialFolderPath("documents")&"/userLoginCridentials.txt" into tFile put URL("file:"&tFile) into myFile
Instead of this "userCridentials.txt" I want something user can create with his own name :)
Having a little problem to understand your question. Are you targeting mobile or desktop? Are you having problem saving or reading the data?
If saving is you problem
On desktop you can use:
ask file "Save file as:"
then you get the filename back in it so you can use:
if it is not empty then
# We have a complete file path in 'it'
put it into tFile
put tData into url ("file:" & tFile)
end if
If you targeting mobile and would like to save into the specialFolderPath("Documents")you can get the filename from a field and then save to that file. E.g. if you have a field named 'fileName' you can use something like:
put tData into url("file:" & specialFolderPath("Documents") & "/" & field "fileName"
Of course you should do some error checking to ensure that a user don't overwrite existing files without at least asking for permission, etc.
You can of course use a variable instead of a field...
If reading data is your problem
On desktop you can use:
answer file "Open File:"
Same as above but you now read data instead:
if it is not empty then
# We have a complete file path in 'it'
put it into tFile
put url ("file:" & tFile) into tData
end if
on mobile you probably would like to present a list with the user-created files. In LiveCode you can list all files in the defaultFolder with the files. But you must set the defaultFolder to the folder you want to list.
set the defaultFolder to specialFolderPath("Documents")
put the files into tFiles
Now tFiles contains every file in that folder and you can filter it, display it in a list etc. E.g:
filter tFiles with "*.txt"
put tFiles into
If your problem is how to remember the "current" file name
Whenever you restart your app every variable is reset. So everything you want to remember between runs needs to be saved before your app quits. And for that you need a predefined filename. SO then your procedure will be:
Read in the predefined file.
Grab the file name from within that file
Read the file
If your problem is something else
Sorry, then I misunderstood your question...