Removing commas and quotes from numeric fields in csv file using SSIS - csv

I am creating SSIS package which reads data from a csv file and stores in SQL Server database. There are a few numeric fields in the csv files.
They sometimes contain value like "1,008.54"
How do I remove the quotes and comma from the value?
I have successfully separated the rows with this kind of data by using Conditional Split Transformation.
(SUBSTRING([Column 9],1,1) == "\"")
After this, I tried using Derived Column Transformation to REPLACE comma and quotes with empty string. But it is not working.
Please advise.
Thanks!

I tested your sample value "1,008.54" in a Data Flow where my source was:
SELECT '"1,008.54"' AS [Column]
I then placed the following expression in a Derived Column Transformation (imitating what you did attempted)
REPLACE(REPLACE(Column,",",""),"\"","")
and successfully achieved your request: Using Derived Column Transformation, REPLACE comma and quotes with empty string.
Here's the result as presented by a data viewer after the Derived Column Transformation:
Column Derived Column 1
"1,008.54" 1008.54

Related

structure in getMetadata activity for csv file dataset ignores an extra comma in the files first row

I am using a reference CSV file with just the correct number and name of columns and want to compare its structure with that of incoming CSV files before proceeding to use Copy Data to import the incoming CSV data into Azure SQL. Files arriving in blob storage trigger this pipeline.
The need to validate the structure has arisen due to random files arriving with a trailing comma in the header row which causes a failure in the copy data pipeline as it sees the trailing comma as an extra column.
I have set up a getMetadata for both the reference file & the incoming files. Using an If Condition, I compare schemas.
The problem I have is that the output of getMetadata is ignoring the trailing comma.
I have tried 'column count' & 'structure' arguments. The same problem either way as the getMetadata fails to see the trailing comma as an issue.
Any help appreciated
I tried with extra commas in header of csv file. Its not ignoring them
reading those extra commas also as columns.
Please check below screenshots.

When writing a csv file to Azure Blob storage, can I configure SSIS to represent NULL as BLANK instead of \N?

I have an SSIS package that queries an Analysis services database and writes the results to Azure Blob Storage as a csv file.
Package is very simple as below. My issue is that NULL values are represented as "\N" and I need them to be BLANK.
There does not appear to be a NULL handling property in the Azure Blob Destination data flow component. Am I missing something / is there a way to change how this component handles NULL values?
Here is the query:
EVALUATE
VAR Customers_csv =
SELECTCOLUMNS (
Customers,
"CustomerID", Customers[CustomerID],
"State", Customers[State]
)
RETURN
Customers_csv
And here is the csv output. The third record is NULL.
CustomerID,State
637099,Kentucky
316102,Kentucky
535357,\N
733735,Kentucky
You can simply add a Derived Column Transformation with the following expression:
REPLACE(REPLACENULL([State],""),"\\N","")
This will replace Nulls and \N values with a blank string.
Update 1
After searching, it looks like \N notation is used to denote NULL value. Check the following links for some workaround:
Datafactory V2 Replace "\N" null value with blank
NULLS in File output are \N and I want them to be empty

Using derived column for trailing zeros

I Have a column IN a SQL table that has these values('NONE','3.00','3.50'). When I export into comma delimited file USING SQL Server integration services I lose my trialing Zeros. I need the values AS is.
In the connection manager for the output file, make sure you have the column meta data set to either of the two STRING data types and then add the double quotes as a text qualifier.

Loading comma separated .csv file into database

I was trying to load a .csv file into my database. It was a comma delimited file and for one of the columns there is a comma(,) in between the data just like Texas,Houston can some one help me how to get rid of the comma in between. the package which i have created recognizing the value after the comma as a new column but it should not be like that. Can any of the guys help me in this. I was getting error in the Flat file source itself. I thought of using Derived column but the package is failing at the source point itself.
Well some "comma" delimited files have ,"something or other", when there is a string and only use ,numeric_value, when its a number type. If your file is like this then you can preprocess your file changing ," for some (other) rare character, and similarly ", then replace the , if it occurs between the two rare characters. Or you can count the comma in any line and if its greater than the number pf delimited columns, manually frocess the exceptions

Lose data in random fields when importing from file into table using phpmyadmin

I have an access DB. I exported tables to xlsx. Then I saved as .ods using openOffice
because I found out that phpmyadmin-mysql no longer supports excel files. I have my mySQL database formated exactly as it should to accept the data. I import and everything seems fine except one little detail.
In some fields, the value is NULL instead of the value it should have according to the .ods file. Some rows show the same value for that field correctly, some show NULL.
Also, the "faulty" rows have some fields that show the value 0 for fields that where empty in the imported file (instead of NULL). Default value for those fields in mySQL is NULL. Each row has many fields like that and all of the same data type (tinyint). Some appear correctly NULL and some have the value 0....
I can't see a pattern on all these.
Any help is appreciated.
Check to see that imported strings have ("") quotes and NULL do not and that all are separated appropriately, usually a "," comma with the record/row delimited by ";" semicolon. Best way to check what the MySQL is looking for is to export some existing data to the same format and check it against what you are trying to import. One little missed quote and the deal is off. Be consistent in the use of either double " quotes or single ' quotes. also the ` character is not used as I think. If you are "squishing" your data through an application that applies "smart quotes" like MS word does or "Open Office??' this too can cause issues. Add the word NULL either inside or without quotes in your csv import where values appropriate.