pipeline delimiter and some fields having comma those should be placed in double quotes and it supposed to be taken as single filed [closed]

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












-3















i Have one csv file.



input.



India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd


output



India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd









share|improve this question















closed as unclear what you're asking by Jeff Schaller, jimmij, Michael Homer, DarkHeart, roaima Mar 7 at 11:50


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 1





    What have you tried so far? How did that attempt deviate from your expectations?

    – Fox
    Mar 6 at 13:27






  • 2





    There are plenty of characters available in the body of your Question to describe the question. Do not feel like you need to fit it all into the title, please & thank you!

    – Jeff Schaller
    Mar 6 at 13:34











  • awk ']+/,""&"")1' i tried this but it is replacing whole data

    – Aswani
    Mar 6 at 13:45











  • awk ']+/,""&"")1' i tried this but it is replacing whole data Input: India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd apple|grape|orange|strawberry|12543|mango output: India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd apple,grape,orange,strawberry,12543,mango or India|Andhra|"asd,ged,ijn"|telangana|41657|"hgjd,dfef,edf|dfd" apple|grape|orange|strawberry|12543|mango

    – Aswani
    Mar 6 at 13:54











  • awk -F| -vOFS=, 'for(i=1;i<=NF;i++)if($i~OFS)$i="""$i"""; print'; but as the other have said, use a csv tool, that knows how to deal with csv's format pitfalls.

    – mosvy
    Mar 6 at 18:59















-3















i Have one csv file.



input.



India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd


output



India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd









share|improve this question















closed as unclear what you're asking by Jeff Schaller, jimmij, Michael Homer, DarkHeart, roaima Mar 7 at 11:50


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 1





    What have you tried so far? How did that attempt deviate from your expectations?

    – Fox
    Mar 6 at 13:27






  • 2





    There are plenty of characters available in the body of your Question to describe the question. Do not feel like you need to fit it all into the title, please & thank you!

    – Jeff Schaller
    Mar 6 at 13:34











  • awk ']+/,""&"")1' i tried this but it is replacing whole data

    – Aswani
    Mar 6 at 13:45











  • awk ']+/,""&"")1' i tried this but it is replacing whole data Input: India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd apple|grape|orange|strawberry|12543|mango output: India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd apple,grape,orange,strawberry,12543,mango or India|Andhra|"asd,ged,ijn"|telangana|41657|"hgjd,dfef,edf|dfd" apple|grape|orange|strawberry|12543|mango

    – Aswani
    Mar 6 at 13:54











  • awk -F| -vOFS=, 'for(i=1;i<=NF;i++)if($i~OFS)$i="""$i"""; print'; but as the other have said, use a csv tool, that knows how to deal with csv's format pitfalls.

    – mosvy
    Mar 6 at 18:59













-3












-3








-3








i Have one csv file.



input.



India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd


output



India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd









share|improve this question
















i Have one csv file.



input.



India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd


output



India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd






awk csv






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 13:35









Kusalananda

139k17259432




139k17259432










asked Mar 6 at 13:24









AswaniAswani

41




41




closed as unclear what you're asking by Jeff Schaller, jimmij, Michael Homer, DarkHeart, roaima Mar 7 at 11:50


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by Jeff Schaller, jimmij, Michael Homer, DarkHeart, roaima Mar 7 at 11:50


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1





    What have you tried so far? How did that attempt deviate from your expectations?

    – Fox
    Mar 6 at 13:27






  • 2





    There are plenty of characters available in the body of your Question to describe the question. Do not feel like you need to fit it all into the title, please & thank you!

    – Jeff Schaller
    Mar 6 at 13:34











  • awk ']+/,""&"")1' i tried this but it is replacing whole data

    – Aswani
    Mar 6 at 13:45











  • awk ']+/,""&"")1' i tried this but it is replacing whole data Input: India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd apple|grape|orange|strawberry|12543|mango output: India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd apple,grape,orange,strawberry,12543,mango or India|Andhra|"asd,ged,ijn"|telangana|41657|"hgjd,dfef,edf|dfd" apple|grape|orange|strawberry|12543|mango

    – Aswani
    Mar 6 at 13:54











  • awk -F| -vOFS=, 'for(i=1;i<=NF;i++)if($i~OFS)$i="""$i"""; print'; but as the other have said, use a csv tool, that knows how to deal with csv's format pitfalls.

    – mosvy
    Mar 6 at 18:59












  • 1





    What have you tried so far? How did that attempt deviate from your expectations?

    – Fox
    Mar 6 at 13:27






  • 2





    There are plenty of characters available in the body of your Question to describe the question. Do not feel like you need to fit it all into the title, please & thank you!

    – Jeff Schaller
    Mar 6 at 13:34











  • awk ']+/,""&"")1' i tried this but it is replacing whole data

    – Aswani
    Mar 6 at 13:45











  • awk ']+/,""&"")1' i tried this but it is replacing whole data Input: India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd apple|grape|orange|strawberry|12543|mango output: India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd apple,grape,orange,strawberry,12543,mango or India|Andhra|"asd,ged,ijn"|telangana|41657|"hgjd,dfef,edf|dfd" apple|grape|orange|strawberry|12543|mango

    – Aswani
    Mar 6 at 13:54











  • awk -F| -vOFS=, 'for(i=1;i<=NF;i++)if($i~OFS)$i="""$i"""; print'; but as the other have said, use a csv tool, that knows how to deal with csv's format pitfalls.

    – mosvy
    Mar 6 at 18:59







1




1





What have you tried so far? How did that attempt deviate from your expectations?

– Fox
Mar 6 at 13:27





What have you tried so far? How did that attempt deviate from your expectations?

– Fox
Mar 6 at 13:27




2




2





There are plenty of characters available in the body of your Question to describe the question. Do not feel like you need to fit it all into the title, please & thank you!

– Jeff Schaller
Mar 6 at 13:34





There are plenty of characters available in the body of your Question to describe the question. Do not feel like you need to fit it all into the title, please & thank you!

– Jeff Schaller
Mar 6 at 13:34













awk ']+/,""&"")1' i tried this but it is replacing whole data

– Aswani
Mar 6 at 13:45





awk ']+/,""&"")1' i tried this but it is replacing whole data

– Aswani
Mar 6 at 13:45













awk ']+/,""&"")1' i tried this but it is replacing whole data Input: India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd apple|grape|orange|strawberry|12543|mango output: India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd apple,grape,orange,strawberry,12543,mango or India|Andhra|"asd,ged,ijn"|telangana|41657|"hgjd,dfef,edf|dfd" apple|grape|orange|strawberry|12543|mango

– Aswani
Mar 6 at 13:54





awk ']+/,""&"")1' i tried this but it is replacing whole data Input: India|Andhra|asd,ged,ijn|telangana|41657|hgjd,dfef,edf|dfd apple|grape|orange|strawberry|12543|mango output: India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd apple,grape,orange,strawberry,12543,mango or India|Andhra|"asd,ged,ijn"|telangana|41657|"hgjd,dfef,edf|dfd" apple|grape|orange|strawberry|12543|mango

– Aswani
Mar 6 at 13:54













awk -F| -vOFS=, 'for(i=1;i<=NF;i++)if($i~OFS)$i="""$i"""; print'; but as the other have said, use a csv tool, that knows how to deal with csv's format pitfalls.

– mosvy
Mar 6 at 18:59





awk -F| -vOFS=, 'for(i=1;i<=NF;i++)if($i~OFS)$i="""$i"""; print'; but as the other have said, use a csv tool, that knows how to deal with csv's format pitfalls.

– mosvy
Mar 6 at 18:59










2 Answers
2






active

oldest

votes


















2














Using csvformat from csvkit:



$ csvformat -d '|' file.csv
India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd


The tools in the csvkit toolbox are CSV-aware (they are all CSV parsers for modifying and querying and generally working with CSV files on the command line).



Here, I use csvformat to reformat the input file and I specify that the field delimiter in the input is a pipe symbol by using -d '|'. The output will by default use commas as field delimiters, and the tool will escape and quote things as necessary.






share|improve this answer























  • awk ']+/,""&"")1' I tried this but it is replacing whole data. I tried with csvformat -d '|' file.csv I'm getting error as -ksh: csvformat: not found [No such file or directory]

    – Aswani
    Mar 6 at 13:45












  • @Aswani csvformat is seldom installed by default. You would have to install csvkit manually. This could be done with pip install --user csvkit and then adding ~/.local/bin to your path.

    – Kusalananda
    Mar 6 at 13:50











  • its a shared server so we dont have rights to install

    – Aswani
    Mar 6 at 14:00











  • @Aswani The command I mentioned would install in your home directory.

    – Kusalananda
    Mar 6 at 14:07











  • when I'm trying to install its prompting error as -ksh: pip: not found [No such file or directory]

    – Aswani
    Mar 6 at 14:12


















0














If you have ruby installed:



ruby -rcsv -e '
rdr = CSV.new(File.new(ARGV.shift), col_sep: "|")
wtr = CSV.new($stdout)
rdr.each row
' file.csv




India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd





share|improve this answer























  • No ruby installed in my server:(

    – Aswani
    Mar 6 at 14:52











  • I'm using putty and im writing unix shell script for file formatting

    – Aswani
    Mar 6 at 14:57

















2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Using csvformat from csvkit:



$ csvformat -d '|' file.csv
India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd


The tools in the csvkit toolbox are CSV-aware (they are all CSV parsers for modifying and querying and generally working with CSV files on the command line).



Here, I use csvformat to reformat the input file and I specify that the field delimiter in the input is a pipe symbol by using -d '|'. The output will by default use commas as field delimiters, and the tool will escape and quote things as necessary.






share|improve this answer























  • awk ']+/,""&"")1' I tried this but it is replacing whole data. I tried with csvformat -d '|' file.csv I'm getting error as -ksh: csvformat: not found [No such file or directory]

    – Aswani
    Mar 6 at 13:45












  • @Aswani csvformat is seldom installed by default. You would have to install csvkit manually. This could be done with pip install --user csvkit and then adding ~/.local/bin to your path.

    – Kusalananda
    Mar 6 at 13:50











  • its a shared server so we dont have rights to install

    – Aswani
    Mar 6 at 14:00











  • @Aswani The command I mentioned would install in your home directory.

    – Kusalananda
    Mar 6 at 14:07











  • when I'm trying to install its prompting error as -ksh: pip: not found [No such file or directory]

    – Aswani
    Mar 6 at 14:12















2














Using csvformat from csvkit:



$ csvformat -d '|' file.csv
India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd


The tools in the csvkit toolbox are CSV-aware (they are all CSV parsers for modifying and querying and generally working with CSV files on the command line).



Here, I use csvformat to reformat the input file and I specify that the field delimiter in the input is a pipe symbol by using -d '|'. The output will by default use commas as field delimiters, and the tool will escape and quote things as necessary.






share|improve this answer























  • awk ']+/,""&"")1' I tried this but it is replacing whole data. I tried with csvformat -d '|' file.csv I'm getting error as -ksh: csvformat: not found [No such file or directory]

    – Aswani
    Mar 6 at 13:45












  • @Aswani csvformat is seldom installed by default. You would have to install csvkit manually. This could be done with pip install --user csvkit and then adding ~/.local/bin to your path.

    – Kusalananda
    Mar 6 at 13:50











  • its a shared server so we dont have rights to install

    – Aswani
    Mar 6 at 14:00











  • @Aswani The command I mentioned would install in your home directory.

    – Kusalananda
    Mar 6 at 14:07











  • when I'm trying to install its prompting error as -ksh: pip: not found [No such file or directory]

    – Aswani
    Mar 6 at 14:12













2












2








2







Using csvformat from csvkit:



$ csvformat -d '|' file.csv
India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd


The tools in the csvkit toolbox are CSV-aware (they are all CSV parsers for modifying and querying and generally working with CSV files on the command line).



Here, I use csvformat to reformat the input file and I specify that the field delimiter in the input is a pipe symbol by using -d '|'. The output will by default use commas as field delimiters, and the tool will escape and quote things as necessary.






share|improve this answer













Using csvformat from csvkit:



$ csvformat -d '|' file.csv
India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd


The tools in the csvkit toolbox are CSV-aware (they are all CSV parsers for modifying and querying and generally working with CSV files on the command line).



Here, I use csvformat to reformat the input file and I specify that the field delimiter in the input is a pipe symbol by using -d '|'. The output will by default use commas as field delimiters, and the tool will escape and quote things as necessary.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 6 at 13:34









KusalanandaKusalananda

139k17259432




139k17259432












  • awk ']+/,""&"")1' I tried this but it is replacing whole data. I tried with csvformat -d '|' file.csv I'm getting error as -ksh: csvformat: not found [No such file or directory]

    – Aswani
    Mar 6 at 13:45












  • @Aswani csvformat is seldom installed by default. You would have to install csvkit manually. This could be done with pip install --user csvkit and then adding ~/.local/bin to your path.

    – Kusalananda
    Mar 6 at 13:50











  • its a shared server so we dont have rights to install

    – Aswani
    Mar 6 at 14:00











  • @Aswani The command I mentioned would install in your home directory.

    – Kusalananda
    Mar 6 at 14:07











  • when I'm trying to install its prompting error as -ksh: pip: not found [No such file or directory]

    – Aswani
    Mar 6 at 14:12

















  • awk ']+/,""&"")1' I tried this but it is replacing whole data. I tried with csvformat -d '|' file.csv I'm getting error as -ksh: csvformat: not found [No such file or directory]

    – Aswani
    Mar 6 at 13:45












  • @Aswani csvformat is seldom installed by default. You would have to install csvkit manually. This could be done with pip install --user csvkit and then adding ~/.local/bin to your path.

    – Kusalananda
    Mar 6 at 13:50











  • its a shared server so we dont have rights to install

    – Aswani
    Mar 6 at 14:00











  • @Aswani The command I mentioned would install in your home directory.

    – Kusalananda
    Mar 6 at 14:07











  • when I'm trying to install its prompting error as -ksh: pip: not found [No such file or directory]

    – Aswani
    Mar 6 at 14:12
















awk ']+/,""&"")1' I tried this but it is replacing whole data. I tried with csvformat -d '|' file.csv I'm getting error as -ksh: csvformat: not found [No such file or directory]

– Aswani
Mar 6 at 13:45






awk ']+/,""&"")1' I tried this but it is replacing whole data. I tried with csvformat -d '|' file.csv I'm getting error as -ksh: csvformat: not found [No such file or directory]

– Aswani
Mar 6 at 13:45














@Aswani csvformat is seldom installed by default. You would have to install csvkit manually. This could be done with pip install --user csvkit and then adding ~/.local/bin to your path.

– Kusalananda
Mar 6 at 13:50





@Aswani csvformat is seldom installed by default. You would have to install csvkit manually. This could be done with pip install --user csvkit and then adding ~/.local/bin to your path.

– Kusalananda
Mar 6 at 13:50













its a shared server so we dont have rights to install

– Aswani
Mar 6 at 14:00





its a shared server so we dont have rights to install

– Aswani
Mar 6 at 14:00













@Aswani The command I mentioned would install in your home directory.

– Kusalananda
Mar 6 at 14:07





@Aswani The command I mentioned would install in your home directory.

– Kusalananda
Mar 6 at 14:07













when I'm trying to install its prompting error as -ksh: pip: not found [No such file or directory]

– Aswani
Mar 6 at 14:12





when I'm trying to install its prompting error as -ksh: pip: not found [No such file or directory]

– Aswani
Mar 6 at 14:12













0














If you have ruby installed:



ruby -rcsv -e '
rdr = CSV.new(File.new(ARGV.shift), col_sep: "|")
wtr = CSV.new($stdout)
rdr.each row
' file.csv




India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd





share|improve this answer























  • No ruby installed in my server:(

    – Aswani
    Mar 6 at 14:52











  • I'm using putty and im writing unix shell script for file formatting

    – Aswani
    Mar 6 at 14:57















0














If you have ruby installed:



ruby -rcsv -e '
rdr = CSV.new(File.new(ARGV.shift), col_sep: "|")
wtr = CSV.new($stdout)
rdr.each row
' file.csv




India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd





share|improve this answer























  • No ruby installed in my server:(

    – Aswani
    Mar 6 at 14:52











  • I'm using putty and im writing unix shell script for file formatting

    – Aswani
    Mar 6 at 14:57













0












0








0







If you have ruby installed:



ruby -rcsv -e '
rdr = CSV.new(File.new(ARGV.shift), col_sep: "|")
wtr = CSV.new($stdout)
rdr.each row
' file.csv




India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd





share|improve this answer













If you have ruby installed:



ruby -rcsv -e '
rdr = CSV.new(File.new(ARGV.shift), col_sep: "|")
wtr = CSV.new($stdout)
rdr.each row
' file.csv




India,Andhra,"asd,ged,ijn",telangana,41657,"hgjd,dfef,edf",dfd






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 6 at 14:38









glenn jackmanglenn jackman

53k573114




53k573114












  • No ruby installed in my server:(

    – Aswani
    Mar 6 at 14:52











  • I'm using putty and im writing unix shell script for file formatting

    – Aswani
    Mar 6 at 14:57

















  • No ruby installed in my server:(

    – Aswani
    Mar 6 at 14:52











  • I'm using putty and im writing unix shell script for file formatting

    – Aswani
    Mar 6 at 14:57
















No ruby installed in my server:(

– Aswani
Mar 6 at 14:52





No ruby installed in my server:(

– Aswani
Mar 6 at 14:52













I'm using putty and im writing unix shell script for file formatting

– Aswani
Mar 6 at 14:57





I'm using putty and im writing unix shell script for file formatting

– Aswani
Mar 6 at 14:57


Popular posts from this blog

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

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?