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

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

Expand Messages
  • chip willis
    Somthing like this: # open the comma delimated file open (TXTFILE, c:/SOARimports/NU_AC_ACTIVE_ADJUNCTS.csv ) or die( Unable to open file ); @lines =
    Message 1 of 2 , Apr 18 11:52 AM
    • 0 Attachment
      Somthing like this:

      # open the comma delimated file
      open (TXTFILE, "c:/SOARimports/NU_AC_ACTIVE_ADJUNCTS.csv") or die("Unable to open file");
      @lines = <TXTFILE>;

      # read file into an array
      foreach $data(@lines) {

      # remove quotes from string
      $data =~ s/"//g;

      #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($UserID,$Fname,$Lname,$Email) = @values;

      Hope this helps
      Chip



      ----- Original Message ----
      From: kiran <polukir@...>
      To: perl-beginner@yahoogroups.com
      Sent: Thursday, April 12, 2007 11:48:35 PM
      Subject: [PBML] Re: How can I remove the quotes from within this array or cvs file?


      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
      >




      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com

      [Non-text portions of this message have been removed]
    • chip willis
      oops, answerd my own post! ... From: kiran To: perl-beginner@yahoogroups.com Sent: Thursday, April 12, 2007 11:48:35 PM Subject: [PBML] Re:
      Message 2 of 2 , Apr 18 11:54 AM
      • 0 Attachment
        oops, answerd my own post!


        ----- Original Message ----
        From: kiran <polukir@...>
        To: perl-beginner@yahoogroups.com
        Sent: Thursday, April 12, 2007 11:48:35 PM
        Subject: [PBML] Re: How can I remove the quotes from within this array or cvs file?


        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
        >




        __________________________________________________
        Do You Yahoo!?
        Tired of spam? Yahoo! Mail has the best spam protection around
        http://mail.yahoo.com

        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.