text to columns in CSV

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-3















I am having data in CSV file as follows in single column:



Input:



Company;C Desc;Region;R Desc;
H;Hindustan;13;Maharashtra;
I;Unilever;28;Dadra;


I would like to change the data Text to Columns with Delimited ';' as follows:



Output:



Company C Desc Region R Desc
H Hindustan 13 Maharashtra
I Unilever 28 Dadra


How to write this scenario in shell script?



input fileOutput file










share|improve this question






























    -3















    I am having data in CSV file as follows in single column:



    Input:



    Company;C Desc;Region;R Desc;
    H;Hindustan;13;Maharashtra;
    I;Unilever;28;Dadra;


    I would like to change the data Text to Columns with Delimited ';' as follows:



    Output:



    Company C Desc Region R Desc
    H Hindustan 13 Maharashtra
    I Unilever 28 Dadra


    How to write this scenario in shell script?



    input fileOutput file










    share|improve this question


























      -3












      -3








      -3








      I am having data in CSV file as follows in single column:



      Input:



      Company;C Desc;Region;R Desc;
      H;Hindustan;13;Maharashtra;
      I;Unilever;28;Dadra;


      I would like to change the data Text to Columns with Delimited ';' as follows:



      Output:



      Company C Desc Region R Desc
      H Hindustan 13 Maharashtra
      I Unilever 28 Dadra


      How to write this scenario in shell script?



      input fileOutput file










      share|improve this question
















      I am having data in CSV file as follows in single column:



      Input:



      Company;C Desc;Region;R Desc;
      H;Hindustan;13;Maharashtra;
      I;Unilever;28;Dadra;


      I would like to change the data Text to Columns with Delimited ';' as follows:



      Output:



      Company C Desc Region R Desc
      H Hindustan 13 Maharashtra
      I Unilever 28 Dadra


      How to write this scenario in shell script?



      input fileOutput file







      shell-script awk






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 13:29









      Rui F Ribeiro

      41.9k1483142




      41.9k1483142










      asked Jun 28 '16 at 7:15









      ramachandra reddyramachandra reddy

      613




      613




















          1 Answer
          1






          active

          oldest

          votes


















          0














          If you have the column utility (most free Unices has):



          $ column -t -s ';' infile.csv >outfile.txt

          $ cat outfile.txt
          Column A
          Company code Company Desc Region Code Region Desc
          H Hindustan 13 Maharashtra
          I Unilever 28 Dadra


          Then it's a matter of inserting the "Column B", "Column C" etc., but it was not clear from the question if these were part of the input/output or not.



          EDIT: After the question was clarified:



          Replace the ; in the CSV file by commas using tr, then re-import the file into Excel.



          $ tr ';' ',' <infile.csv >outfile.csv


          Excel should also be able to import your original data if you specify ; as column delimiters. I'm no Excel user though so I can't help with that.






          share|improve this answer

























          • thanks for quick response. I need to split the data in output file as shown in the images. Like text to columns feature in excel

            – ramachandra reddy
            Jun 28 '16 at 7:33











          • @ramachandrareddyAha! I will update my answer... (after thinking).

            – Kusalananda
            Jun 28 '16 at 7:36












          • Dear Kusalananda, Your command is working fine after modifying my CSV header. Thank you so much for your efforts. Very much appreciated your inputs

            – ramachandra reddy
            Jun 28 '16 at 13:35











          • @ramachandrareddy I'm happy you got it sorted. You may consider "accepting" the answer by clicking the tick under the up-vote/down-vote buttons here to the left. Thanks.

            – Kusalananda
            Jun 28 '16 at 14:20











          • Dear Kusalananda, thank you for your inputs. I am having numeric data also. Once it is saving into CSV all the formats are changing. Like amount (numbers) coming as "1777686.23-" instead of "-1777686.23" Please let me know how to get this minus sign as a prefix instead of suffix

            – ramachandra reddy
            Jun 29 '16 at 10:08











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f292519%2ftext-to-columns-in-csv%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          If you have the column utility (most free Unices has):



          $ column -t -s ';' infile.csv >outfile.txt

          $ cat outfile.txt
          Column A
          Company code Company Desc Region Code Region Desc
          H Hindustan 13 Maharashtra
          I Unilever 28 Dadra


          Then it's a matter of inserting the "Column B", "Column C" etc., but it was not clear from the question if these were part of the input/output or not.



          EDIT: After the question was clarified:



          Replace the ; in the CSV file by commas using tr, then re-import the file into Excel.



          $ tr ';' ',' <infile.csv >outfile.csv


          Excel should also be able to import your original data if you specify ; as column delimiters. I'm no Excel user though so I can't help with that.






          share|improve this answer

























          • thanks for quick response. I need to split the data in output file as shown in the images. Like text to columns feature in excel

            – ramachandra reddy
            Jun 28 '16 at 7:33











          • @ramachandrareddyAha! I will update my answer... (after thinking).

            – Kusalananda
            Jun 28 '16 at 7:36












          • Dear Kusalananda, Your command is working fine after modifying my CSV header. Thank you so much for your efforts. Very much appreciated your inputs

            – ramachandra reddy
            Jun 28 '16 at 13:35











          • @ramachandrareddy I'm happy you got it sorted. You may consider "accepting" the answer by clicking the tick under the up-vote/down-vote buttons here to the left. Thanks.

            – Kusalananda
            Jun 28 '16 at 14:20











          • Dear Kusalananda, thank you for your inputs. I am having numeric data also. Once it is saving into CSV all the formats are changing. Like amount (numbers) coming as "1777686.23-" instead of "-1777686.23" Please let me know how to get this minus sign as a prefix instead of suffix

            – ramachandra reddy
            Jun 29 '16 at 10:08















          0














          If you have the column utility (most free Unices has):



          $ column -t -s ';' infile.csv >outfile.txt

          $ cat outfile.txt
          Column A
          Company code Company Desc Region Code Region Desc
          H Hindustan 13 Maharashtra
          I Unilever 28 Dadra


          Then it's a matter of inserting the "Column B", "Column C" etc., but it was not clear from the question if these were part of the input/output or not.



          EDIT: After the question was clarified:



          Replace the ; in the CSV file by commas using tr, then re-import the file into Excel.



          $ tr ';' ',' <infile.csv >outfile.csv


          Excel should also be able to import your original data if you specify ; as column delimiters. I'm no Excel user though so I can't help with that.






          share|improve this answer

























          • thanks for quick response. I need to split the data in output file as shown in the images. Like text to columns feature in excel

            – ramachandra reddy
            Jun 28 '16 at 7:33











          • @ramachandrareddyAha! I will update my answer... (after thinking).

            – Kusalananda
            Jun 28 '16 at 7:36












          • Dear Kusalananda, Your command is working fine after modifying my CSV header. Thank you so much for your efforts. Very much appreciated your inputs

            – ramachandra reddy
            Jun 28 '16 at 13:35











          • @ramachandrareddy I'm happy you got it sorted. You may consider "accepting" the answer by clicking the tick under the up-vote/down-vote buttons here to the left. Thanks.

            – Kusalananda
            Jun 28 '16 at 14:20











          • Dear Kusalananda, thank you for your inputs. I am having numeric data also. Once it is saving into CSV all the formats are changing. Like amount (numbers) coming as "1777686.23-" instead of "-1777686.23" Please let me know how to get this minus sign as a prefix instead of suffix

            – ramachandra reddy
            Jun 29 '16 at 10:08













          0












          0








          0







          If you have the column utility (most free Unices has):



          $ column -t -s ';' infile.csv >outfile.txt

          $ cat outfile.txt
          Column A
          Company code Company Desc Region Code Region Desc
          H Hindustan 13 Maharashtra
          I Unilever 28 Dadra


          Then it's a matter of inserting the "Column B", "Column C" etc., but it was not clear from the question if these were part of the input/output or not.



          EDIT: After the question was clarified:



          Replace the ; in the CSV file by commas using tr, then re-import the file into Excel.



          $ tr ';' ',' <infile.csv >outfile.csv


          Excel should also be able to import your original data if you specify ; as column delimiters. I'm no Excel user though so I can't help with that.






          share|improve this answer















          If you have the column utility (most free Unices has):



          $ column -t -s ';' infile.csv >outfile.txt

          $ cat outfile.txt
          Column A
          Company code Company Desc Region Code Region Desc
          H Hindustan 13 Maharashtra
          I Unilever 28 Dadra


          Then it's a matter of inserting the "Column B", "Column C" etc., but it was not clear from the question if these were part of the input/output or not.



          EDIT: After the question was clarified:



          Replace the ; in the CSV file by commas using tr, then re-import the file into Excel.



          $ tr ';' ',' <infile.csv >outfile.csv


          Excel should also be able to import your original data if you specify ; as column delimiters. I'm no Excel user though so I can't help with that.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 28 '16 at 7:43

























          answered Jun 28 '16 at 7:25









          KusalanandaKusalananda

          140k17261435




          140k17261435












          • thanks for quick response. I need to split the data in output file as shown in the images. Like text to columns feature in excel

            – ramachandra reddy
            Jun 28 '16 at 7:33











          • @ramachandrareddyAha! I will update my answer... (after thinking).

            – Kusalananda
            Jun 28 '16 at 7:36












          • Dear Kusalananda, Your command is working fine after modifying my CSV header. Thank you so much for your efforts. Very much appreciated your inputs

            – ramachandra reddy
            Jun 28 '16 at 13:35











          • @ramachandrareddy I'm happy you got it sorted. You may consider "accepting" the answer by clicking the tick under the up-vote/down-vote buttons here to the left. Thanks.

            – Kusalananda
            Jun 28 '16 at 14:20











          • Dear Kusalananda, thank you for your inputs. I am having numeric data also. Once it is saving into CSV all the formats are changing. Like amount (numbers) coming as "1777686.23-" instead of "-1777686.23" Please let me know how to get this minus sign as a prefix instead of suffix

            – ramachandra reddy
            Jun 29 '16 at 10:08

















          • thanks for quick response. I need to split the data in output file as shown in the images. Like text to columns feature in excel

            – ramachandra reddy
            Jun 28 '16 at 7:33











          • @ramachandrareddyAha! I will update my answer... (after thinking).

            – Kusalananda
            Jun 28 '16 at 7:36












          • Dear Kusalananda, Your command is working fine after modifying my CSV header. Thank you so much for your efforts. Very much appreciated your inputs

            – ramachandra reddy
            Jun 28 '16 at 13:35











          • @ramachandrareddy I'm happy you got it sorted. You may consider "accepting" the answer by clicking the tick under the up-vote/down-vote buttons here to the left. Thanks.

            – Kusalananda
            Jun 28 '16 at 14:20











          • Dear Kusalananda, thank you for your inputs. I am having numeric data also. Once it is saving into CSV all the formats are changing. Like amount (numbers) coming as "1777686.23-" instead of "-1777686.23" Please let me know how to get this minus sign as a prefix instead of suffix

            – ramachandra reddy
            Jun 29 '16 at 10:08
















          thanks for quick response. I need to split the data in output file as shown in the images. Like text to columns feature in excel

          – ramachandra reddy
          Jun 28 '16 at 7:33





          thanks for quick response. I need to split the data in output file as shown in the images. Like text to columns feature in excel

          – ramachandra reddy
          Jun 28 '16 at 7:33













          @ramachandrareddyAha! I will update my answer... (after thinking).

          – Kusalananda
          Jun 28 '16 at 7:36






          @ramachandrareddyAha! I will update my answer... (after thinking).

          – Kusalananda
          Jun 28 '16 at 7:36














          Dear Kusalananda, Your command is working fine after modifying my CSV header. Thank you so much for your efforts. Very much appreciated your inputs

          – ramachandra reddy
          Jun 28 '16 at 13:35





          Dear Kusalananda, Your command is working fine after modifying my CSV header. Thank you so much for your efforts. Very much appreciated your inputs

          – ramachandra reddy
          Jun 28 '16 at 13:35













          @ramachandrareddy I'm happy you got it sorted. You may consider "accepting" the answer by clicking the tick under the up-vote/down-vote buttons here to the left. Thanks.

          – Kusalananda
          Jun 28 '16 at 14:20





          @ramachandrareddy I'm happy you got it sorted. You may consider "accepting" the answer by clicking the tick under the up-vote/down-vote buttons here to the left. Thanks.

          – Kusalananda
          Jun 28 '16 at 14:20













          Dear Kusalananda, thank you for your inputs. I am having numeric data also. Once it is saving into CSV all the formats are changing. Like amount (numbers) coming as "1777686.23-" instead of "-1777686.23" Please let me know how to get this minus sign as a prefix instead of suffix

          – ramachandra reddy
          Jun 29 '16 at 10:08





          Dear Kusalananda, thank you for your inputs. I am having numeric data also. Once it is saving into CSV all the formats are changing. Like amount (numbers) coming as "1777686.23-" instead of "-1777686.23" Please let me know how to get this minus sign as a prefix instead of suffix

          – ramachandra reddy
          Jun 29 '16 at 10:08

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f292519%2ftext-to-columns-in-csv%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

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay