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

Concatenation

Expand Messages
  • billkirk23
    I am reading in an input file. The file is a column of names and addresses. I then want to concatenate the name and address on one line with quotes and
    Message 1 of 5 , May 17, 2010
      I am reading in an input file. The file is a column of names and addresses. I then want to concatenate the name and address on one line with quotes and separate the name, address, and zip by a comma. Basically creating a .CSV file that will be imported to Excel for making labels.

      I am using the "." operator for the concatenation. The problem is in the output. the last quote goes to the next line: i.e.

      "Joe Smith
      "

      Any suggestions?

      Thanks
    • merlyn@stonehenge.com
      ... billkirk23 I am reading in an input file. The file is a column of billkirk23 names and addresses. I then want to concatenate the name billkirk23 and
      Message 2 of 5 , May 17, 2010
        >>>>> "billkirk23" == billkirk23 <billkirk23@...> writes:

        billkirk23> I am reading in an input file. The file is a column of
        billkirk23> names and addresses. I then want to concatenate the name
        billkirk23> and address on one line with quotes and separate the name,
        billkirk23> address, and zip by a comma. Basically creating a .CSV file
        billkirk23> that will be imported to Excel for making labels.

        Ahh, then use any of the CSV modules, such as Text::CSV. Then you don't
        need to reinvent an often over-reinvented wheel.

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
        See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
      • mike lively
        Actually there are modules you can use to easily create the spreadsheet directly out of Perl. Eliminating the need for the CSV file. I have found creating
        Message 3 of 5 , May 17, 2010
          Actually there are modules you can use to easily create the spreadsheet directly out of Perl. Eliminating the need for the CSV file. I have found creating the spreadsheet in Perl makes it much easier for anyone that really needs the data in spreadsheet form rather than having to import the data. There are several options for formating the cells so the spreadsheet looks really nice and easy to read.



          Mike


          >
          > >>>>> "billkirk23" == billkirk23 <billkirk23@...> writes:
          >
          > billkirk23> I am reading in an input file. The file is a column of
          > billkirk23> names and addresses. I then want to concatenate the name
          > billkirk23> and address on one line with quotes and separate the name,
          > billkirk23> address, and zip by a comma. Basically creating a .CSV file
          > billkirk23> that will be imported to Excel for making labels.
          >
          > Ahh, then use any of the CSV modules, such as Text::CSV. Then you don't
          > need to reinvent an often over-reinvented wheel.
          >
          > --
          > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
          > <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
          > Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
          > See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
          >



          [Non-text portions of this message have been removed]
        • wkirk195@comcast.net
          I have downloaded TEXT::CSV. Now how is it used? I want to input a text file and have a CSV output. Also I am not sure I have installed on my version of Perl
          Message 4 of 5 , May 18, 2010
            I have downloaded TEXT::CSV. Now how is it used? I want to input a text file and have a CSV output. Also I am not sure I have installed on my version of Perl correctly. I unzipped the file and then put CSV.PM in the Text directory, but I'm not sure if that is correct.

            I am using Strawberry Perl

            Thanks.
            ----- Original Message -----
            From: merlyn@...
            To: "billkirk23" <billkirk23@...>
            Cc: perl-beginner@yahoogroups.com
            Sent: Monday, May 17, 2010 2:56:17 PM GMT -05:00 US/Canada Eastern
            Subject: Re: [PBML] Concatenation






            >>>>> "billkirk23" == billkirk23 < billkirk23@... > writes:

            billkirk23> I am reading in an input file. The file is a column of
            billkirk23> names and addresses. I then want to concatenate the name
            billkirk23> and address on one line with quotes and separate the name,
            billkirk23> address, and zip by a comma. Basically creating a .CSV file
            billkirk23> that will be imported to Excel for making labels.

            Ahh, then use any of the CSV modules, such as Text::CSV. Then you don't
            need to reinvent an often over-reinvented wheel.

            --
            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
            < merlyn@... > <URL: http://www.stonehenge.com/merlyn/ >
            Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
            See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion



            [Non-text portions of this message have been removed]
          • Robert Binkley
            #!/usr/bin/perl     use strict;     use warnings;     use Text::CSV;     my $file = prospects.csv ;     my $csv = Text::CSV- new();     open
            Message 5 of 5 , May 18, 2010
              #!/usr/bin/perl
                  use strict;
                  use warnings;
                  use Text::CSV;

                  my $file = 'prospects.csv';

                  my $csv = Text::CSV->new();

                  open (CSV, "<", $file) or die $!;

                  while (<CSV>) {
                      if ($csv->parse($_)) {
                          my @columns = $csv->fields();
                          print "@columns\n";
                      } else {
                          my $err = $csv->error_input;
                          print "Failed to parse line: $err";
                      }
                  }
                  close CSV;



              >
              >From: "wkirk195@..." <wkirk195@...>
              >To: perl-beginner@yahoogroups.com
              >Sent: Tue, May 18, 2010 11:42:31 AM
              >Subject: Re: [PBML] Concatenation
              >

              >I have downloaded TEXT::CSV. Now how is it used? I want to input a text file and have a CSV output. Also I am not sure I have installed on my version of Perl correctly. I unzipped the file and then put CSV.PM in the Text directory, but I'm not sure if that is correct.
              >
              >I am using Strawberry Perl
              >
              >Thanks.
              >----- Original Message -----
              >From: merlyn@...
              >To: "billkirk23" <billkirk23@...>
              >Cc: perl-beginner@yahoogroups.com
              >Sent: Monday, May 17, 2010 2:56:17 PM GMT -05:00 US/Canada Eastern
              >Subject: Re: [PBML] Concatenation
              >
              >>>>>> "billkirk23" == billkirk23 < billkirk23@... > writes:
              >
              >billkirk23> I am reading in an input file. The file is a column of
              >billkirk23> names and addresses. I then want to concatenate the name
              >billkirk23> and address on one line with quotes and separate the name,
              >billkirk23> address, and zip by a comma. Basically creating a .CSV file
              >billkirk23> that will be imported to Excel for making labels.
              >
              >Ahh, then use any of the CSV modules, such as Text::CSV. Then you don't
              >need to reinvent an often over-reinvented wheel.
              >
              >--
              >Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
              >< merlyn@... > <URL: http://www.stonehenge.com/merlyn/ >
              >Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
              >See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
              >
              >[Non-text portions of this message have been removed]
              >
              >
              >




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