SSIS - remove character when it has alphabetic character infront en behind it











up vote
3
down vote

favorite
1












Let's say I have data imported from a csv in SSIS that looks like this:



ID,Name,Year,Place
1,"John",1994,"UK"
2,"Bill",1899,"USA"
3,"Gill",1989,"Germ"any"


In this case, there is a typo in Germany



I was wondering if there was a way (in derived column component maybe) to remove the " When the text is like _"_



_ being an alphabetic character or space.



This question came close to what I needed: SSIS - remove character X unless it's followed by character Y , but it's done in SQL, while my data is in SSIS from a csv.










share|improve this question
























  • The wayward " is going to break the validity of the CSV. if you're using a double quote (") as the text identifier and it can appear in your data you need to use a different text identifier.
    – Larnu
    yesterday












  • @DenStudent: Only by SSIS you want to do? If so then there has inbuilt functionality for that!
    – im_one
    18 hours ago

















up vote
3
down vote

favorite
1












Let's say I have data imported from a csv in SSIS that looks like this:



ID,Name,Year,Place
1,"John",1994,"UK"
2,"Bill",1899,"USA"
3,"Gill",1989,"Germ"any"


In this case, there is a typo in Germany



I was wondering if there was a way (in derived column component maybe) to remove the " When the text is like _"_



_ being an alphabetic character or space.



This question came close to what I needed: SSIS - remove character X unless it's followed by character Y , but it's done in SQL, while my data is in SSIS from a csv.










share|improve this question
























  • The wayward " is going to break the validity of the CSV. if you're using a double quote (") as the text identifier and it can appear in your data you need to use a different text identifier.
    – Larnu
    yesterday












  • @DenStudent: Only by SSIS you want to do? If so then there has inbuilt functionality for that!
    – im_one
    18 hours ago















up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





Let's say I have data imported from a csv in SSIS that looks like this:



ID,Name,Year,Place
1,"John",1994,"UK"
2,"Bill",1899,"USA"
3,"Gill",1989,"Germ"any"


In this case, there is a typo in Germany



I was wondering if there was a way (in derived column component maybe) to remove the " When the text is like _"_



_ being an alphabetic character or space.



This question came close to what I needed: SSIS - remove character X unless it's followed by character Y , but it's done in SQL, while my data is in SSIS from a csv.










share|improve this question















Let's say I have data imported from a csv in SSIS that looks like this:



ID,Name,Year,Place
1,"John",1994,"UK"
2,"Bill",1899,"USA"
3,"Gill",1989,"Germ"any"


In this case, there is a typo in Germany



I was wondering if there was a way (in derived column component maybe) to remove the " When the text is like _"_



_ being an alphabetic character or space.



This question came close to what I needed: SSIS - remove character X unless it's followed by character Y , but it's done in SQL, while my data is in SSIS from a csv.







sql-server ssis






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked yesterday









DenStudent

5381625




5381625












  • The wayward " is going to break the validity of the CSV. if you're using a double quote (") as the text identifier and it can appear in your data you need to use a different text identifier.
    – Larnu
    yesterday












  • @DenStudent: Only by SSIS you want to do? If so then there has inbuilt functionality for that!
    – im_one
    18 hours ago




















  • The wayward " is going to break the validity of the CSV. if you're using a double quote (") as the text identifier and it can appear in your data you need to use a different text identifier.
    – Larnu
    yesterday












  • @DenStudent: Only by SSIS you want to do? If so then there has inbuilt functionality for that!
    – im_one
    18 hours ago


















The wayward " is going to break the validity of the CSV. if you're using a double quote (") as the text identifier and it can appear in your data you need to use a different text identifier.
– Larnu
yesterday






The wayward " is going to break the validity of the CSV. if you're using a double quote (") as the text identifier and it can appear in your data you need to use a different text identifier.
– Larnu
yesterday














@DenStudent: Only by SSIS you want to do? If so then there has inbuilt functionality for that!
– im_one
18 hours ago






@DenStudent: Only by SSIS you want to do? If so then there has inbuilt functionality for that!
– im_one
18 hours ago














3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










The answer that @Sami posted is a good option, and if you are specifically aiming to use a derived column for this then the following expression will remove any " while still keeping the leading and trailing double quotes. Make sure to escape the " with a character, otherwise the SSIS expression will fail.



""" + REPLACE(Place,""","") + """





share|improve this answer




























    up vote
    1
    down vote













    You can do like



    CREATE TABLE T
    ([ID] int, [Name] varchar(45), [Year] int, [Place] varchar(45));

    INSERT INTO T
    ([ID], [Name], [Year], [Place])
    VALUES
    (1, '"John"', 1994, '"UK"'),
    (2, '"Bill"', 1899, '"USA"'),
    (3, '"Gill"', 1989, '"Germ"an"y"');

    SELECT ID,
    Name,
    [Year],
    CONCAT('"', REPLACE(Place, '"', ''), '"') Place
    FROM T;


    Returns:



    +----+--------+------+-----------+
    | ID | Name | Year | Place |
    +----+--------+------+-----------+
    | 1 | "John" | 1994 | "UK" |
    | 2 | "Bill" | 1899 | "USA" |
    | 3 | "Gill" | 1989 | "Germany" |
    +----+--------+------+-----------+


    Demo






    share|improve this answer






























      up vote
      0
      down vote













      If understood your question correctly!



      There has inbuilt functionality to avoid such characters from FLAT-FILE.



      As shown in below image, just add your Special character "Text qualifier" in Flat-file Connection String. As I have inserted DOUBLE-QUOTE("). Best thing in this is that You no need to have your special character in each columns and rows! It will only TRIM the text where your special characters do exist from both the sides of text!



      enter image description here



      Please do comment if this is not enough! But hope this will help you!






      share|improve this answer





















        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














         

        draft saved


        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372467%2fssis-remove-character-when-it-has-alphabetic-character-infront-en-behind-it%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        1
        down vote



        accepted










        The answer that @Sami posted is a good option, and if you are specifically aiming to use a derived column for this then the following expression will remove any " while still keeping the leading and trailing double quotes. Make sure to escape the " with a character, otherwise the SSIS expression will fail.



        """ + REPLACE(Place,""","") + """





        share|improve this answer

























          up vote
          1
          down vote



          accepted










          The answer that @Sami posted is a good option, and if you are specifically aiming to use a derived column for this then the following expression will remove any " while still keeping the leading and trailing double quotes. Make sure to escape the " with a character, otherwise the SSIS expression will fail.



          """ + REPLACE(Place,""","") + """





          share|improve this answer























            up vote
            1
            down vote



            accepted







            up vote
            1
            down vote



            accepted






            The answer that @Sami posted is a good option, and if you are specifically aiming to use a derived column for this then the following expression will remove any " while still keeping the leading and trailing double quotes. Make sure to escape the " with a character, otherwise the SSIS expression will fail.



            """ + REPLACE(Place,""","") + """





            share|improve this answer












            The answer that @Sami posted is a good option, and if you are specifically aiming to use a derived column for this then the following expression will remove any " while still keeping the leading and trailing double quotes. Make sure to escape the " with a character, otherwise the SSIS expression will fail.



            """ + REPLACE(Place,""","") + """






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            userfl89

            1,01149




            1,01149
























                up vote
                1
                down vote













                You can do like



                CREATE TABLE T
                ([ID] int, [Name] varchar(45), [Year] int, [Place] varchar(45));

                INSERT INTO T
                ([ID], [Name], [Year], [Place])
                VALUES
                (1, '"John"', 1994, '"UK"'),
                (2, '"Bill"', 1899, '"USA"'),
                (3, '"Gill"', 1989, '"Germ"an"y"');

                SELECT ID,
                Name,
                [Year],
                CONCAT('"', REPLACE(Place, '"', ''), '"') Place
                FROM T;


                Returns:



                +----+--------+------+-----------+
                | ID | Name | Year | Place |
                +----+--------+------+-----------+
                | 1 | "John" | 1994 | "UK" |
                | 2 | "Bill" | 1899 | "USA" |
                | 3 | "Gill" | 1989 | "Germany" |
                +----+--------+------+-----------+


                Demo






                share|improve this answer



























                  up vote
                  1
                  down vote













                  You can do like



                  CREATE TABLE T
                  ([ID] int, [Name] varchar(45), [Year] int, [Place] varchar(45));

                  INSERT INTO T
                  ([ID], [Name], [Year], [Place])
                  VALUES
                  (1, '"John"', 1994, '"UK"'),
                  (2, '"Bill"', 1899, '"USA"'),
                  (3, '"Gill"', 1989, '"Germ"an"y"');

                  SELECT ID,
                  Name,
                  [Year],
                  CONCAT('"', REPLACE(Place, '"', ''), '"') Place
                  FROM T;


                  Returns:



                  +----+--------+------+-----------+
                  | ID | Name | Year | Place |
                  +----+--------+------+-----------+
                  | 1 | "John" | 1994 | "UK" |
                  | 2 | "Bill" | 1899 | "USA" |
                  | 3 | "Gill" | 1989 | "Germany" |
                  +----+--------+------+-----------+


                  Demo






                  share|improve this answer

























                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    You can do like



                    CREATE TABLE T
                    ([ID] int, [Name] varchar(45), [Year] int, [Place] varchar(45));

                    INSERT INTO T
                    ([ID], [Name], [Year], [Place])
                    VALUES
                    (1, '"John"', 1994, '"UK"'),
                    (2, '"Bill"', 1899, '"USA"'),
                    (3, '"Gill"', 1989, '"Germ"an"y"');

                    SELECT ID,
                    Name,
                    [Year],
                    CONCAT('"', REPLACE(Place, '"', ''), '"') Place
                    FROM T;


                    Returns:



                    +----+--------+------+-----------+
                    | ID | Name | Year | Place |
                    +----+--------+------+-----------+
                    | 1 | "John" | 1994 | "UK" |
                    | 2 | "Bill" | 1899 | "USA" |
                    | 3 | "Gill" | 1989 | "Germany" |
                    +----+--------+------+-----------+


                    Demo






                    share|improve this answer














                    You can do like



                    CREATE TABLE T
                    ([ID] int, [Name] varchar(45), [Year] int, [Place] varchar(45));

                    INSERT INTO T
                    ([ID], [Name], [Year], [Place])
                    VALUES
                    (1, '"John"', 1994, '"UK"'),
                    (2, '"Bill"', 1899, '"USA"'),
                    (3, '"Gill"', 1989, '"Germ"an"y"');

                    SELECT ID,
                    Name,
                    [Year],
                    CONCAT('"', REPLACE(Place, '"', ''), '"') Place
                    FROM T;


                    Returns:



                    +----+--------+------+-----------+
                    | ID | Name | Year | Place |
                    +----+--------+------+-----------+
                    | 1 | "John" | 1994 | "UK" |
                    | 2 | "Bill" | 1899 | "USA" |
                    | 3 | "Gill" | 1989 | "Germany" |
                    +----+--------+------+-----------+


                    Demo







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited yesterday

























                    answered yesterday









                    Sami

                    6,27531038




                    6,27531038






















                        up vote
                        0
                        down vote













                        If understood your question correctly!



                        There has inbuilt functionality to avoid such characters from FLAT-FILE.



                        As shown in below image, just add your Special character "Text qualifier" in Flat-file Connection String. As I have inserted DOUBLE-QUOTE("). Best thing in this is that You no need to have your special character in each columns and rows! It will only TRIM the text where your special characters do exist from both the sides of text!



                        enter image description here



                        Please do comment if this is not enough! But hope this will help you!






                        share|improve this answer

























                          up vote
                          0
                          down vote













                          If understood your question correctly!



                          There has inbuilt functionality to avoid such characters from FLAT-FILE.



                          As shown in below image, just add your Special character "Text qualifier" in Flat-file Connection String. As I have inserted DOUBLE-QUOTE("). Best thing in this is that You no need to have your special character in each columns and rows! It will only TRIM the text where your special characters do exist from both the sides of text!



                          enter image description here



                          Please do comment if this is not enough! But hope this will help you!






                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            If understood your question correctly!



                            There has inbuilt functionality to avoid such characters from FLAT-FILE.



                            As shown in below image, just add your Special character "Text qualifier" in Flat-file Connection String. As I have inserted DOUBLE-QUOTE("). Best thing in this is that You no need to have your special character in each columns and rows! It will only TRIM the text where your special characters do exist from both the sides of text!



                            enter image description here



                            Please do comment if this is not enough! But hope this will help you!






                            share|improve this answer












                            If understood your question correctly!



                            There has inbuilt functionality to avoid such characters from FLAT-FILE.



                            As shown in below image, just add your Special character "Text qualifier" in Flat-file Connection String. As I have inserted DOUBLE-QUOTE("). Best thing in this is that You no need to have your special character in each columns and rows! It will only TRIM the text where your special characters do exist from both the sides of text!



                            enter image description here



                            Please do comment if this is not enough! But hope this will help you!







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 17 hours ago









                            im_one

                            313114




                            313114






























                                 

                                draft saved


                                draft discarded



















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372467%2fssis-remove-character-when-it-has-alphabetic-character-infront-en-behind-it%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                'app-layout' is not a known element: how to share Component with different Modules

                                android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                                WPF add header to Image with URL pettitions [duplicate]