Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. $ echo '"BARCELONA";"";"Country.666;53";15' | csvtool -t ';' col 1- -
  2. BARCELONA,,Country.666;53,15
  3.  
  4. $ echo '"BARCELONA";"";"Country.666;53";15' | csvtool -t ';' col 1,3 -
  5. BARCELONA,Country.666;53
  6.  
  7. $ perl -MText::CSV -lpe '
  8. BEGIN{$p = Text::CSV->new({sep_char => ";"})}
  9. $_ = join "|", map { /^d+$/ ? $_ : qq("$_") } $p->fields() if $p->parse($_)
  10. ' INPUT
  11. "BARCELONA"|""|"Country.666;53;98"|15|19|"test"|4343|63647|655848
  12.  
  13. $ csvformat -d';' -D'|' INPUT
  14. BARCELONA||Country.666;53;98|15|19|test|4343|63647|655848
  15.  
  16. $ csvformat -d';' -u2 -D'|' -U2 INPUT
  17. "BARCELONA"|""|"Country.666;53;98"|15.0|19.0|"test"|4343.0|63647.0|655848.0
  18.  
  19. cat file.txt | awk -v FPAT='[^;]+|"[^"]+"' '{ for( col=1; col<=NF; col++ ) { printf "%s|", $col; } print "" }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement