Find the answer to your Linux question:
Results 1 to 3 of 3
Need to remove all commas in the CSV file and save it in an array using perl... example : first.csv { 10,654,7,86,85,85,5,532,53,798,} output.csv should look like this.. {10 644 7 ...
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    9

    perl to read csv file

    Need to remove all commas in the CSV file and save it in an array using perl...

    example :

    first.csv
    { 10,654,7,86,85,85,5,532,53,798,}

    output.csv should look like this..
    {10 644 7 86 85 85 5 532 53 798}

  2. #2
    Just Joined! jaysunn's Avatar
    Join Date
    Apr 2009
    Location
    New York City - USA
    Posts
    18
    I am not perl expert. However you can try this. I am not sure how to put it in a array.

    Code:
    perl -p -i -e "s/,/ /g " first.csv > ouput.csv
    I have tested and it successfully removes your commas.

    Jaysunn

  3. #3
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Code:
    awk -F"," '{$1=$1}1' OFS=" "

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...