Domanda

I'm having a problem getting data from a .CSV into a column of datatype FLOAT. I've tried to link it directly and also use the Data Conversion Task, but (in both cases) it kept telling me that it couldn't convert:

Error: 0xC02020C5 at DC_Weekly_Cost_Target csv to FatzWklyCst_Target, Data Conversion [156]: Data conversion failed while converting column "Target" (22) to column "Copy of Target" (163).  The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".

My research led me to using the Derived Column Transformation Editor. I found a few websites that walked me through how properly use the "Expression" portion:

enter image description here

Above is how I'm attempting to transform the strings (Target and Waste) into datatype Float. I'm not receiving an error message when using the Editor (i.e. It will let me clik OK without an error), however, I am receiving an error when I attempt to run the package:

Error: 0xC0049064 at DC_Weekly_Cost_Target csv to FatzWklyCst_Target, Map Target in correct datatype 1 1 [222]: An error occurred while attempting to perform a type cast.

Error: 0xC0209029 at DC_Weekly_Cost_Target csv to FatzWklyCst_Target, Map Target in correct datatype 1 1 [222]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "component "Map Target in correct datatype 1 1" (222)" failed because error code 0xC0049064 occurred, and the error row disposition on "output column "Target_Float" (227)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.

Error: 0xC0047022 at DC_Weekly_Cost_Target csv to FatzWklyCst_Target, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "Map Target in correct datatype 1 1" (222) failed with error code 0xC0209029 while processing input "Derived Column Input" (223). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the failure.

This is my first time using the Derived Column Transformation Editor. Does anyone see what I'm doing incorrectly? Or, do you have any suggestions as to what may be the best approach to getting data from a .csv file into a column of datatype float? I appreciate any help that anyone can give me.

È stato utile?

Soluzione

You have tried a reasonable approach but something in the data is blowing it up - possibly "invalid" characters e.g. $ or ,

I would replace the Derived Column transformation with a Script Task. There you can leverage the .NET Framework e.g. Try ... Catch, TryParse, Regex. You can debug your code line-by-line to inspect the rows with errors. You can also use Reflection to factor your conversion code as a function that you call for each column passed into the Script Task.

PS: your destination is irrelevant.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top