So I have a text file with lots of data I want to load into plsql.
I have successfully completed this task using a batch file for the majority of the text file, but names with a " in the name threw up an error.
For example, some names are things like Sally"s Bakery instead of Sally's Bakery.
I get an error:
no terminator found after TERMINATED and ENCLOSED field
Does anyone know a way to get around it?
Related
I basiclly need to remove some text from file name and there is multiple file. I think I made a mistake. File name was baddly changed eg. 1.9.1.json --> 1form.9.1.json. I expected 1.9.1form.json. Here is code that I tried:
ren *.json ???form.*
I am looking for a code to undo this, and fix of my code that I tried.
Please don't explane it since I am python coder and I even have no idea to print Hello world in batch.
Note: I can't change it one by one since there is fifty files.
I am getting a "File not found" error with trying to run Outlook in batch. Most likely due to an error in the way I am formatting the code. The script takes the contents of clipboard provided by 'getclip' as %1, zips it to clips.zip, uses && to pass to ipmnote which attaches it to a pre-loaded Outlook email
My original layout (which works) uses more lines of code and includes a mid-step of creating a file to be compressed. In trying to simplify the routine, I am getting errors saying Outlook cannot be found.
Outlook.exe is already in my System Path and I normally call it in using only the exe name. But I get the same "can't be located" error even when adding full path the file as shown here.
getclip>7z.exe a Clips.zip %1 -y && "C:\Program Files (x86)\Microsoft
Office\root\Office16\OUTLOOK.exe" /c ipm.note /m "email&subject=CLips.zip"
/a Clips.zip
Thanks for the quick reply. But the problem was the attachment. The error shown is somewhat open to interpretation since it implies that the issue is that Outlook cannot be found. In fact, what it could not find was the "clips.zip" file needed to attach it. Once i added the path to find the attachment, it works perfectly.
Sometimes, it helps to write in and ask the question. By following testing the sequence for each step of the outlook command, i found the issue was only there when i added the attachment with the /a at the end. By giving the full path to find 'clips.zip', all errors are gone and the email is perfect.
The broken line in the code was created by posting the code using the "Code" button. I added characters as needed to force it to display properly
I am sure there is a better way and I started to mention this but i figured most people would know that the proper path to Outlook especially being in quotes and all would not have a carriage return in the middle"
I need to extract the object name from a sql text file. All of my sql files have as their 1st line "CREATE some type [schema name].[object name]. Sometimes the brackets are there, other times not. In either case, I need to be able to discern the object name affected so I can determine if it actually exists before updating the server with the new changes. I need to do this from a Windows 7 command line batch file. Not powershell, please.
Doing this in a batch file is a bit like working without your hands tied behind your back, but if you insist, I would suggest the following:
Get the first line of the file (you said in the comments that you can already do this).
Split the line on spaces and get the x-th value.
Split the resulting value on the dot.
Strip the backets from the value.
Voila. It won't be easy, it won't be readable, but it will do what you need and it will be a Windows cmd batch file.
"The specified path, file name, or both are too long.
The fully qualified file name must be less than 260 characters,
and the directory name must be less than 248 characters"
That is the error whenever I try to move a file from one folder to other.
The same file is getting loaded into a table but when I try to move, its throwing the error.
I am using a file system task to move the file from one folder to another. The file system task is throwing out that error.
Did anyone encounter the same error? How did you overcome? Please help me solve this error..
There is a tool to address just this. Can be found at http://PathTooDeep.com
Alternately you can use expressions to rename and move the file using a File System task.
I am trying to load data from text files to database. My source files contain null character NUL somehow (Picture1).
I just make all the fields as one column (delimited with {CR}{LF}). Then I do the preview of the data.
The data is just what we need.
But then when I run the package, the data changed, not like what I see in data preview. I added a data viewer to see the data.
The number 1 disappear in the first row (see the red). It seems that flat file reading ends at NUL character. But my Row delimiter is {CR}{LF}, it doesn't make sense the number 1 in the end disappear. Can anyone tell me why is that?
Reproducing the error
First of all, I would like to show the steps to reproduce this error using Notepad++ editor.
I created a text file called TestNUL that contains data similar to the screenshot posted in the question (commas are placed where NUL objects should be):
Now, Go To Edit menu strip >> Character Panel
Now the ASCII character panel is shown, double click on the NULL value in order to add it to the text:
Now the text file will looks like:
You can use the following link to download the file:
TestNUL.txt
Removing NUL character using Notepad++
To remove this character you can simply open Notepad++, Click Ctrl + H to open the Find and Replace dialog. Then select to use Regular Expressions and replace \x00 with an empty string:
All NUL characters are removed:
Find and replace in multiple file
If you are looking to find and replace this character in multiple files, then you can use notepad++ to do this using Find in Files feature:
How to find and replace line(s) in multiple files using Notepad++?
How to Find and Replace Words in Multiple Files
Automating the process Within SSIS
Since the issue occurs at run-time not while previewing data, you can simply add a Script Task before the data flow task to replace all \x00 values with an empty string. You can read the text file path from the flat file connection manager or you can store it in a variable. You can use a similar C# code:
public void Main()
{
string FilePath = Dts.Connections["SourceConnection"].ConnectionString;
string text = System.IO.File.ReadAllText(FilePath);
text = text.Replace(Convert.ToChar(0x0).ToString(), "");
System.IO.File.WriteAllText(FilePath, text);
Dts.TaskResult = (int)ScriptResults.Success;
}
If you are working with large text files then you can use System.IO.StreamReader and System.IO.StreamWriter classes to read the file line by line using ReadLine() function.
How to read a large (1 GB) txt file in .NET?
How can I read, replace and write very large files?
Experiments
I created a package and added two flat file connection manager, the source reads from TestNUL.txt file and the destination create a new TestNUL_edited.txt file with the same structure. I added a Script Task with the code above and added a data viewer in the Data Flow Task, the following screenshot shows how the rows are not corrupted:
Also the following screenshot shows how the NUL values are removed from the source file after running the Script Task:
References
Notepad++ showing null values after crash
How to Insert a Null Character (ASCII 00) in Notepad?
What does \x00 mean in binary file?
Find/Replace nul objects in Notepad++
Removing "NUL" characters
How to Find And Replace Text In A File With C#
Map every field in his column (using Tab {t} as column delimiter I suppose, and {CR}{LF} as row delimiter) and try again.