Loading ...
Sorry, an error occurred while loading the content.

Re: How can I remove the quotes from within this array or cvs file?

Expand Messages
  • kiran
    Hi, You can use ..split with the pattern / / and get rid of the quotes in the array@values. Something like this .....split(/ /,@values); should do. Rgds, Kiran
    Message 1 of 3 , Apr 12, 2007
    • 0 Attachment
      Hi,
      You can use ..split with the pattern /"/ and get rid of the quotes
      in the array@values.

      Something like this .....split(/"/,@values);

      should do.

      Rgds,
      Kiran Polu


      --- In perl-beginner@yahoogroups.com, "chipwillis2003"
      <chipwillis2003@...> wrote:
      >
      > How can I remove the quotes from within this array?
      > Or would I read the entire file first and remove the quotes from it
      > first?
      > Can I get an example of the best solution?
      > Here is my code:
      >
      > # open the comma delimated file
      > open (TXTFILE, "c:/SOARimports/NU_AD2032_ILINC_EXTRACT_stf.csv") or
      > die("Unable to open file");
      > @lines = <TXTFILE>;
      >
      > # read file into an array
      > foreach $data(@lines) {
      > #loop through file putting users in array here
      > # split the line of text by comma
      > my @values = split(',', $data);
      >
      > # put the line into an array
      > my($InstructorID,$InstFname,$InstLname,$InstEmail) = @values;
      >
      > Here is an example of the cvs file:
      > "100043093","Long,Paul",longps@...
      >
      > I need to remove the quotes.
      > Thank you,
      > Chip
      >
    • Yogesh Sawant
      ... $data =~ s/ //g; # remove all double quotes
      Message 2 of 3 , Apr 13, 2007
      • 0 Attachment
        --- In perl-beginner@yahoogroups.com, "chipwillis2003"
        <chipwillis2003@...> wrote:
        >
        > How can I remove the quotes from within this array?
        > Or would I read the entire file first and remove the quotes from it
        > first?
        > Can I get an example of the best solution?
        > Here is my code:
        >
        > # open the comma delimated file
        > open (TXTFILE, "c:/SOARimports/NU_AD2032_ILINC_EXTRACT_stf.csv") or
        > die("Unable to open file");
        > @lines = <TXTFILE>;
        >
        > # read file into an array
        > foreach $data(@lines) {
        > #loop through file putting users in array here

        $data =~ s/\"//g; # remove all double quotes

        > # split the line of text by comma
        > my @values = split(',', $data);
        >
        > # put the line into an array
        > my($InstructorID,$InstFname,$InstLname,$InstEmail) = @values;
        >
        > Here is an example of the cvs file:
        > "100043093","Long,Paul",longps@...
        >
        > I need to remove the quotes.
        > Thank you,
        > Chip
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.