How to convert CSV with % with SSIS
Hello all the experience SSIS user out there,
Here's the code for my source file csv formatted:
"ID","Video Name","Views","Viewed Minutes","Percentage to 50% Mark","Percentage to 75% Mark","Percentage of Complete Views"
"71579527001","Royal Distributing Inc","164","72","84%","75%","73%"
"79545950001","Session de formation Montréal - Nouveaux produits","150","227","65%","60%","42%"
"71597962001","Alibi Coiffure","139","56","80%","68%","65%"
"71605945001","Attache De Remorque Québec","127","99","71%","64%","62%"
"71593233001","Maison Victoria (La)","117","99","80%","70%","58%"
"71586694001","La Faune Domestique","117","47","76%","64%","64%"
"71603800001","Ameublement Lida Furniture Inc","112","54","82%","76%","74%"
"71585732001","Restaurant Sushi Oshima (Le)","112","100","84%","75%","69%"
"71581693001","Josie Bridal Shop","111","46","69%","56%","54%"
"71601401001","Couvreur René Perron Ltée","111","88","77%","65%","62%"
"71608107001","Carousel Dance Centre","109","108","76%","70%","50%"
"71592877001","Funtropolis Centre D'Amusements","101","45","90%","78%","73%"
"71601182001","Deckpro Services","100","8","13%","9%","9%"
"71596726001","Harmonie Internationale","92","34","85%","81%","77%"
"71596499001","Clinique d'Ophtalmologie De La Cité","90","75","75%","74%","71%"
"71579800001","Elégance Nuptiale","88","69","71%","64%","55%"
"71577985001","Recherché Concept Coiffure","84","66","70%","61%","52%"
"74488537001","Clôture Frost Inc","84","38","88%","76%","73%"
"71578965001","Balcon Royal Inc","83","30","90%","77%","69%"
"71581121001","Mail Champlain","82","30","75%","53%","52%"
"71606315001","D B M Aluminium et Fer Ornemental","82","34","76%","69%","69%"
"71600040001","Éco Dépôt Céramique","78","34","84%","79%","76%"
"71580482001","Clinique De Chirurgie Esthétique Serge Côté","77","39","85%","74%","68%"
"71598955001","Boutique France B Pronuptia","77","33","74%","59%","59%"
"71593738001","ABC Cycles & Sports Ltée","76","31","80%","65%","63%"
"71597777001","Clôture Générale","75","29","81%","77%","73%"
"71602952001","La Trattoria","74","29","70%","66%","63%"
"74615662001","Fillion Asphalte Pavage Inc","74","36","66%","55%","54%"
"71608922001","Carole Cyr Dre","71","62","85%","76%","69%"
"71602172001","Centre le Décapeur A C Inc","68","53","73%","64%","61%"
"71885875001","Ecole De Danse Anacaona","67","60","88%","71%","65%"
"71584905001","Audace Andrel Coiffure","66","27","89%","66%","62%"
"71885900001","Blu Coiffure et Esthétique","64","32","89%","78%","75%"
"71578774001","Clôtures Sentinelle Ltée","62","23","91%","79%","72%"
"71588081001","Jamo Entreprises Paysagistes","62","28","82%","72%","70%"
"71589273001","Allard François Dr","61","57","85%","77%","70%"
"71605948001","Restaurant Le Jardin De Panos","60","24","76%","65%","60%"
"71582458001","Acme Shelving & Store Fixtures","59","48","74%","55%","50%"
"71601686001","Primeau Vélo","59","26","86%","83%","77%"
"71588430001","Archambault Claude Entreprises","58","29","91%","79%","74%"
"71589228001","Vieux Four Manago (Le)","58","31","86%","79%","77%"
"71607383001","Ultra Limousine","57","27","89%","77%","77%"
"71597766001","Kitchen Magic","57","53","80%","71%","71%"
"71582905001","Verti Store","57","26","84%","80%","78%"
"71585131001","Paysagiste P M T","56","24","83%","73%","73%"
"71605260001","Guylaine Martel Artistes Coiffeurs","56","46","75%","71%","69%"
"71588049001","Centre Du Comptoir Moulé","56","23","83%","73%","69%"
"71608312001","Restaurant Rouge","56","22","78%","66%","66%"
"71590568001","Services Vétérinaires Henri-Bourassa","56","56","83%","76%","60%"
"71581501001","Denis Musique Inc","55","35","60%","50%","47%"
I would like to convert the percentage to an interger, but this is the error msg i got "[Data Conversion [88]] Error: Data conversion failed while converting column "Percentage to 75% Mark" (52) to column "Copy of Percentage to 75% Mark"
(142). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
I think SSIS looking see the field as text or character, and refuses to convert it into a number. Is there anything I can do to tell SSIS ignore the @ sign? Please advise... thank you very much.
May 5th, 2010 7:08am
Yes, the percentage columns are read as string. Try to remove % and then convert using a derived column as: (DT_I4)REPLACE(ColumnName,"%","")Nitesh Rai- Please mark the post as answered if it answers your question
Free Windows Admin Tool Kit Click here and download it now
May 5th, 2010 7:25am
Thanks for the reply, is there a built in feature to do this in SSIS? I want to automate the process.
May 5th, 2010 7:51am
There is no such build in feature. you just need to use derived column to repalce this as Nitesh's mention.
Let us TRY this |
http://quest4gen.blogspot.com/
Free Windows Admin Tool Kit Click here and download it now
May 5th, 2010 8:02am
is there a built in feature to do this in SSIS? I want to automate the process.
Once you add the logic in derived column component (which is part of SSIS data flow task and can be seen as a kind of built in feature to manipulate the data), it will take care of conversion to integer. Now, I am not able to understand what process you want
to automate?Nitesh Rai- Please mark the post as answered if it answers your question
May 5th, 2010 8:09am
I understand this question has been answered, but there's something here I don't get.
If I set a column up in a flat file connection as a currency data type, the package has no problems if it encounters a dollar sign.
Why is it, then, that if I set up a column as a numeric with precision or a float, the package blows up if it encounters a percent sign?
Free Windows Admin Tool Kit Click here and download it now
October 22nd, 2010 4:34am
I would imagine the parser thinks the % sign is like it's wildcard brethren and as such thinks it's a string.
October 22nd, 2010 4:46am