SSIS remove Left zero from csv Flat File Source - ssis

I have a csv file that I want to process in SSIS. The file contains a column type string Unicode string [DT_WSTR], example: ColumnA -> ("00000123400").
I want to delete the zeroes that are on the left of 123400 and also delete the quotes and have a result as following: 123400.
For quotation marks I find the following solution via Derived Column: REPLACE (ColumnA, "\" "," "), which gives me the following result: 00000123400.
How to remove the zeroes which are on the left?
After deleting the quotation marks, I tried to convert my string to integer [DT_I4], but that does not remove the zeroes.
Do you have the answer to my case? Thanks in advance.

The solution of a part of the case is:
in our Derived column put the expression:
REPLACE(LTRIM(REPLACE(ColumnA,"0","")),"","0")
It remove just left zero
you can see the link: Removing left padding zero in SSIS
It work perfectly, but is it possible to trim left zero, and also delete quotation marks in the same time in expression?
Example: I have Column1 which is string with quotation marks and left zero - "0000123400"
I try this expression:
REPLACE(REPLACE(LTRIM(REPLACE(column1, "0", " ")), " ", "0"),"\""," ")
but it doesn't work, it deletes all zeros and returns 1234.
The solution that I want is to get 123400.
Should I do it one by one? Create a delivered column and delete quotation marks first, and after create an other delivered column for Left zero ?
Thanks in advance.

It looks like you want the output to be in numeric form? If so, the following expression will remove the quotes and leading zeros while preserving the trailing zeros from Unicode text. This can be done in a single operation, with one Derived Column that will create a new column (add a new column option) with an integer output data type in the data flow.
(DT_I4)REPLACE(ColumnA,"\"","")
If you want to keep this as the Unicode data type the expression below will do this, also in a single Derived Column. Just adjust the length according to your columns.
(DT_WSTR, 50)(DT_I4)REPLACE(CoulmnA,"\"","")

Related

Pyspark How to Ignore Double quotes from the data present in the CSV files

I am having " (single quotes) in my data ,all the corresponding column values clubbed into one column even though I have used the delimiter value. In my case '|' is my delimiter.
Actual Data:
a|"b|c|d|
Expected Output:
a|"b|c|d
Actual Output Came:
a|"b**|c|d|**null|null| ( here 3rd & 4th column coming as single column, in place of actual 3rd & 4th col.. getting values as null)
I have tried below approach:
Approach 1:
df=spark.read.csv(filepath,header=True,sep='|',quote='')
Above approach gives particular column data correctly but empty columns coming values as """" but we need empty column as it is.
Approach 2:
df=spark.read.csv(filepath,header=True,sep='|',quote='',escape='\"')
Above approach gives values clubbing into single column as like actual output.
After some heads & trails
found solution
read the file with both below options :
quote='',escape='\"'

SSIS Flat File add trailing spaces to columns

I am developing a SSIS package which concatenates 3 columns and then outputs the result to a flat file.
1st column is a emp_number consists of length 10.
The values which I get is "12345" or "123456" or "1234567".
In the output I want is "12345 " or "123456 " or "1234567 "
I have a requirement wherein I need to have columns of fixed size(10), so if the length a value for a particular column is lesser than
the expected length I need to pad or fill it with spaces so that the length is matched.
Can you please help.
Add a Derived Column transformation that takes the column value, concatenates it to a string made up of 10 spaces (or whatever the total length after padding should be) and then take the rightmost 10 chars using an expression:
RIGHT("0000000000" + yourcol, 10)
Similar to iamdave's answer but you need the reverse:
left(yourcolumn + " ",10)
There are 10 spaces between the quotes.
if your column is not a string you need to cast it:
left((DT_WSTR,10)yourcolumn + " ",10)

easy way to query without putting everything in quotation marks

How do I query in MySql without putting all inserts in quotations? (I have a big list and it would take to much time to quote and unquote every word)
Example:
SELECT *
FROM names
WHERE names.first IN ("joe", "tom", "vincent")
Since you said the list is comma separated, simply use the 'find and replace' feature to find all commas and replace them with ","
The result should be joe","tom","vincent"," which you can simply copy into mysql.
All you then have to do is edit the start and end of the string

Select from a field containing spaces using MySQL

I'm attempting to query on a field/column/table in a MySQL DB where the field type is varchar, but some values contains spaces. In my query, I tried to put the exact string to match on in single quotes in a where clause. However, the only rows that are returned are the strings that do not contain spaces.
Here are the values stored in the table/column:
Here is the query and the result that is only returning fields without spaces:
I expected to find a row for "New Business", a row for "Monetary Endorsement", etc. Any idea on how I can modify my query to return the desired fields? Thanks for your help in advance!
Maybe the other values have leading or trailing spaces. You can either use one of the suggestion below:
1.) Use TRIM()
WHERE TRIM(PTD_TRANS_TYPE) = 'NEW BUSINESS'
2.) Use LIKE
WHERE PTD_TRANS_TYPE LIKE '%NEW BUSINESS%'
Here's a Demo.

To find and replace escaped quotes in MySQL table

My database has content that has been previously escaped, resulting in string such as
This value is \"invalid\".
I want to get rid of escape character \ but I'm having a hard time to find these rows. My first attempt
select value from content where value like '%\\"%';
fails to separate \" from ", and returns valid rows such as
This value is "valid".
So how can I query for the string \", preferably in a way than can be used in an update clause to remove the slash?
EDIT: SQL Fiddle here http://sqlfiddle.com/#!9/fc3d3/6
Notice that the query at line 3 returns both rows.
I've checked your sqlfiddle.
This gets the invalid rows:
SELECT * from myTable where content<>REPLACE(content,'\\\"','\"')
If this works, then you can simply update your content column to REPLACE(content,'\\\"','\"').