text to columns in CSV
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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?
shell-script awk
add a comment |
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?
shell-script awk
add a comment |
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?
shell-script awk
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?
shell-script awk
shell-script awk
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
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
|
show 3 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
|
show 3 more comments
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.
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
|
show 3 more comments
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.
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.
edited Jun 28 '16 at 7:43
answered Jun 28 '16 at 7:25
Kusalananda♦Kusalananda
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
|
show 3 more comments
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
|
show 3 more comments
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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