Convert CSV to tab delimit file in AIX server
I have a requirement to transform a csv to a tab delimited file.
But the problem is, I have “,” within name field which I need to maintain.
Source:
Amsterdam, “last name, first name”, Europe
Output:
Amsterdamtlast name, first nametEurope
aix csv
add a comment |
I have a requirement to transform a csv to a tab delimited file.
But the problem is, I have “,” within name field which I need to maintain.
Source:
Amsterdam, “last name, first name”, Europe
Output:
Amsterdamtlast name, first nametEurope
aix csv
3
the file contains non-standard quotes
– RomanPerekhrest
Jan 16 at 14:17
The source data when you open in Microsoft excel it maintains the data integrity as we’ll as my application which processes it. But this has to be processed by an new application which cannot differentiate between comma as delimiter and comma as part of data. Since it can handle tab delimited I am trying to change it to tab format.
– user2704230
Jan 16 at 14:23
do you python installed? also, what's yourawk --version
?
– RomanPerekhrest
Jan 16 at 14:33
@user2704230 yes, tab-separated is a good alternative. See if you can get whoever is exporting the Excel file for you to select TAB as the delimiter when they export. otherwise your best bet would be to use a language with a real CSV parser (CSV has a lot more quirks and oddities and corner cases than most people think, and it's difficult to handle them all with just regular expressions). perl or python, for example.
– cas
Jan 16 at 14:49
@RomanPerekhrest I am not able to find the version ok awk on my aix server. But I do know that I am using 7.1 version of aix.
– user2704230
Jan 16 at 15:12
add a comment |
I have a requirement to transform a csv to a tab delimited file.
But the problem is, I have “,” within name field which I need to maintain.
Source:
Amsterdam, “last name, first name”, Europe
Output:
Amsterdamtlast name, first nametEurope
aix csv
I have a requirement to transform a csv to a tab delimited file.
But the problem is, I have “,” within name field which I need to maintain.
Source:
Amsterdam, “last name, first name”, Europe
Output:
Amsterdamtlast name, first nametEurope
aix csv
aix csv
edited Jan 16 at 14:14
Jeff Schaller
38.7k1053125
38.7k1053125
asked Jan 16 at 14:10
user2704230
61
61
3
the file contains non-standard quotes
– RomanPerekhrest
Jan 16 at 14:17
The source data when you open in Microsoft excel it maintains the data integrity as we’ll as my application which processes it. But this has to be processed by an new application which cannot differentiate between comma as delimiter and comma as part of data. Since it can handle tab delimited I am trying to change it to tab format.
– user2704230
Jan 16 at 14:23
do you python installed? also, what's yourawk --version
?
– RomanPerekhrest
Jan 16 at 14:33
@user2704230 yes, tab-separated is a good alternative. See if you can get whoever is exporting the Excel file for you to select TAB as the delimiter when they export. otherwise your best bet would be to use a language with a real CSV parser (CSV has a lot more quirks and oddities and corner cases than most people think, and it's difficult to handle them all with just regular expressions). perl or python, for example.
– cas
Jan 16 at 14:49
@RomanPerekhrest I am not able to find the version ok awk on my aix server. But I do know that I am using 7.1 version of aix.
– user2704230
Jan 16 at 15:12
add a comment |
3
the file contains non-standard quotes
– RomanPerekhrest
Jan 16 at 14:17
The source data when you open in Microsoft excel it maintains the data integrity as we’ll as my application which processes it. But this has to be processed by an new application which cannot differentiate between comma as delimiter and comma as part of data. Since it can handle tab delimited I am trying to change it to tab format.
– user2704230
Jan 16 at 14:23
do you python installed? also, what's yourawk --version
?
– RomanPerekhrest
Jan 16 at 14:33
@user2704230 yes, tab-separated is a good alternative. See if you can get whoever is exporting the Excel file for you to select TAB as the delimiter when they export. otherwise your best bet would be to use a language with a real CSV parser (CSV has a lot more quirks and oddities and corner cases than most people think, and it's difficult to handle them all with just regular expressions). perl or python, for example.
– cas
Jan 16 at 14:49
@RomanPerekhrest I am not able to find the version ok awk on my aix server. But I do know that I am using 7.1 version of aix.
– user2704230
Jan 16 at 15:12
3
3
the file contains non-standard quotes
– RomanPerekhrest
Jan 16 at 14:17
the file contains non-standard quotes
– RomanPerekhrest
Jan 16 at 14:17
The source data when you open in Microsoft excel it maintains the data integrity as we’ll as my application which processes it. But this has to be processed by an new application which cannot differentiate between comma as delimiter and comma as part of data. Since it can handle tab delimited I am trying to change it to tab format.
– user2704230
Jan 16 at 14:23
The source data when you open in Microsoft excel it maintains the data integrity as we’ll as my application which processes it. But this has to be processed by an new application which cannot differentiate between comma as delimiter and comma as part of data. Since it can handle tab delimited I am trying to change it to tab format.
– user2704230
Jan 16 at 14:23
do you python installed? also, what's your
awk --version
?– RomanPerekhrest
Jan 16 at 14:33
do you python installed? also, what's your
awk --version
?– RomanPerekhrest
Jan 16 at 14:33
@user2704230 yes, tab-separated is a good alternative. See if you can get whoever is exporting the Excel file for you to select TAB as the delimiter when they export. otherwise your best bet would be to use a language with a real CSV parser (CSV has a lot more quirks and oddities and corner cases than most people think, and it's difficult to handle them all with just regular expressions). perl or python, for example.
– cas
Jan 16 at 14:49
@user2704230 yes, tab-separated is a good alternative. See if you can get whoever is exporting the Excel file for you to select TAB as the delimiter when they export. otherwise your best bet would be to use a language with a real CSV parser (CSV has a lot more quirks and oddities and corner cases than most people think, and it's difficult to handle them all with just regular expressions). perl or python, for example.
– cas
Jan 16 at 14:49
@RomanPerekhrest I am not able to find the version ok awk on my aix server. But I do know that I am using 7.1 version of aix.
– user2704230
Jan 16 at 15:12
@RomanPerekhrest I am not able to find the version ok awk on my aix server. But I do know that I am using 7.1 version of aix.
– user2704230
Jan 16 at 15:12
add a comment |
2 Answers
2
active
oldest
votes
Perhaps something like sed -e 's/, "/t/g' -e 's/", /t/g' < intput_file
would help. The sed
expressions replace , "
with t
and ",
with t
.
add a comment |
Hi with Miller is simple. With
echo 'Amsterdam,"last name, first name",Europe' |
mlr --c2t --implicit-csv-header --headerless-csv-output cat
You have
Amsterdamtlast name, first nametEurope
--c2t
is forCSV to TSV
;
--implicit-csv-header
and--headerless-csv-output
to set that there is no header both input and output
add a comment |
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%2f417521%2fconvert-csv-to-tab-delimit-file-in-aix-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Perhaps something like sed -e 's/, "/t/g' -e 's/", /t/g' < intput_file
would help. The sed
expressions replace , "
with t
and ",
with t
.
add a comment |
Perhaps something like sed -e 's/, "/t/g' -e 's/", /t/g' < intput_file
would help. The sed
expressions replace , "
with t
and ",
with t
.
add a comment |
Perhaps something like sed -e 's/, "/t/g' -e 's/", /t/g' < intput_file
would help. The sed
expressions replace , "
with t
and ",
with t
.
Perhaps something like sed -e 's/, "/t/g' -e 's/", /t/g' < intput_file
would help. The sed
expressions replace , "
with t
and ",
with t
.
answered Oct 24 at 20:44
james
464
464
add a comment |
add a comment |
Hi with Miller is simple. With
echo 'Amsterdam,"last name, first name",Europe' |
mlr --c2t --implicit-csv-header --headerless-csv-output cat
You have
Amsterdamtlast name, first nametEurope
--c2t
is forCSV to TSV
;
--implicit-csv-header
and--headerless-csv-output
to set that there is no header both input and output
add a comment |
Hi with Miller is simple. With
echo 'Amsterdam,"last name, first name",Europe' |
mlr --c2t --implicit-csv-header --headerless-csv-output cat
You have
Amsterdamtlast name, first nametEurope
--c2t
is forCSV to TSV
;
--implicit-csv-header
and--headerless-csv-output
to set that there is no header both input and output
add a comment |
Hi with Miller is simple. With
echo 'Amsterdam,"last name, first name",Europe' |
mlr --c2t --implicit-csv-header --headerless-csv-output cat
You have
Amsterdamtlast name, first nametEurope
--c2t
is forCSV to TSV
;
--implicit-csv-header
and--headerless-csv-output
to set that there is no header both input and output
Hi with Miller is simple. With
echo 'Amsterdam,"last name, first name",Europe' |
mlr --c2t --implicit-csv-header --headerless-csv-output cat
You have
Amsterdamtlast name, first nametEurope
--c2t
is forCSV to TSV
;
--implicit-csv-header
and--headerless-csv-output
to set that there is no header both input and output
answered 1 hour ago
aborruso
1215
1215
add a comment |
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f417521%2fconvert-csv-to-tab-delimit-file-in-aix-server%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
3
the file contains non-standard quotes
– RomanPerekhrest
Jan 16 at 14:17
The source data when you open in Microsoft excel it maintains the data integrity as we’ll as my application which processes it. But this has to be processed by an new application which cannot differentiate between comma as delimiter and comma as part of data. Since it can handle tab delimited I am trying to change it to tab format.
– user2704230
Jan 16 at 14:23
do you python installed? also, what's your
awk --version
?– RomanPerekhrest
Jan 16 at 14:33
@user2704230 yes, tab-separated is a good alternative. See if you can get whoever is exporting the Excel file for you to select TAB as the delimiter when they export. otherwise your best bet would be to use a language with a real CSV parser (CSV has a lot more quirks and oddities and corner cases than most people think, and it's difficult to handle them all with just regular expressions). perl or python, for example.
– cas
Jan 16 at 14:49
@RomanPerekhrest I am not able to find the version ok awk on my aix server. But I do know that I am using 7.1 version of aix.
– user2704230
Jan 16 at 15:12