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

Searching 3 files?

Expand Messages
  • Jeff
    ... Hi all- I m trying to open a master file, and see if data in that file exists in the other two files, if not, report it. I just really suck at
    Message 1 of 6 , Mar 31 1:20 PM
    • 0 Attachment
      :q!
      Hi all-

      I'm trying to open a master file, and see if data in that file exists
      in the other two files, if not, report it. I just really suck at
      programing.. LOL I can conceptualize the steps involved, but can't
      seem to make it happen.

      Here's how my files look...


      Libr_Vols.csv
      400000,FF,home,"0,1,0,5,1",STK1R
      400001,FF,home,"0,1,18,13,0",STK1R
      400002,FF,home,"0,1,12,10,4",STK1R
      400003,FF,home,"0,1,18,0,11",STK1R
      400004,FF,home,"0,1,4,7,14",STK1R

      Libr_Scr.csv
      400002,FF,home,"0,1,12,10,4",100,STK1R
      400010,FF,home,"0,0,4,4,23",100,STK1R
      400011,FF,home,"0,1,19,10,7",100,STK1R
      400024,FF,home,"0,1,19,0,13",100,STK1R
      400038,FF,home,"0,1,15,1,2",100,STK1R
      400048,FF,home,"0,1,5,4,4",900,STK1R

      TSM_Usage.csv
      400001,FF,STGNEW,3/25/2005
      400003,FF,STGDELETE,3/7/2005
      400003,FF,STGNEW,3/7/2005
      400019,FF,STGDELETE,3/7/2005
      400021,FF,STGDELETE,3/10/2005
      400021,FF,STGNEW,3/10/2005


      Basically, open the file Libr_Vols.csv, then open Libr_Scr.csv and
      TSM_Usage.csv. If the value exists (for example 400002), then do
      nothing. If it can't be found in either of the two files (Libr_Scr or
      TSM_Usage) then throw it out to a log file.

      Any ideas on how to make it happen??

      Thanks in advance!!!!
    • Scot Robnett
      Try writing some code and letting the group help you modify it. Generally you will get better help if everyone sees you have at least tried something instead
      Message 2 of 6 , Mar 31 1:39 PM
      • 0 Attachment
        Try writing some code and letting the group help you modify it. Generally
        you will get better help if everyone sees you have at least tried something
        instead of asking for it to be done for you. These might help you get
        started:

        perlfunc
        (go to 'open FILEHANDLE')

        perlfaq2

        perlfaq3

        perlfaq4

        You can also find all of this information on CPAN, www.cpan.org.

        Scot R.
        inSite



        -----Original Message-----
        From: Jeff [mailto:g_garrison@...]
        Sent: Thursday, March 31, 2005 3:21 PM
        To: perl-beginner@yahoogroups.com
        Subject: [PBML] Searching 3 files?




        :q!
        Hi all-

        I'm trying to open a master file, and see if data in that file exists
        in the other two files, if not, report it. I just really suck at
        programing.. LOL I can conceptualize the steps involved, but can't
        seem to make it happen.

        Here's how my files look...


        Libr_Vols.csv
        400000,FF,home,"0,1,0,5,1",STK1R
        400001,FF,home,"0,1,18,13,0",STK1R
        400002,FF,home,"0,1,12,10,4",STK1R
        400003,FF,home,"0,1,18,0,11",STK1R
        400004,FF,home,"0,1,4,7,14",STK1R

        Libr_Scr.csv
        400002,FF,home,"0,1,12,10,4",100,STK1R
        400010,FF,home,"0,0,4,4,23",100,STK1R
        400011,FF,home,"0,1,19,10,7",100,STK1R
        400024,FF,home,"0,1,19,0,13",100,STK1R
        400038,FF,home,"0,1,15,1,2",100,STK1R
        400048,FF,home,"0,1,5,4,4",900,STK1R

        TSM_Usage.csv
        400001,FF,STGNEW,3/25/2005
        400003,FF,STGDELETE,3/7/2005
        400003,FF,STGNEW,3/7/2005
        400019,FF,STGDELETE,3/7/2005
        400021,FF,STGDELETE,3/10/2005
        400021,FF,STGNEW,3/10/2005


        Basically, open the file Libr_Vols.csv, then open Libr_Scr.csv and
        TSM_Usage.csv. If the value exists (for example 400002), then do
        nothing. If it can't be found in either of the two files (Libr_Scr or
        TSM_Usage) then throw it out to a log file.

        Any ideas on how to make it happen??

        Thanks in advance!!!!





        Unsubscribing info is here:
        http://help.yahoo.com/help/us/groups/groups-32.html
        Yahoo! Groups Links









        --
        No virus found in this incoming message.
        Checked by AVG Anti-Virus.
        Version: 7.0.308 / Virus Database: 266.8.4 - Release Date: 3/27/2005

        --
        No virus found in this outgoing message.
        Checked by AVG Anti-Virus.
        Version: 7.0.308 / Virus Database: 266.8.4 - Release Date: 3/27/2005
      • Offer Kaye
        ... Here s one way. There are many others :-) ##################### begin code my %seen; update_seen( Libr_Scr.csv ); update_seen( TSM_Usage.csv ); my $infile
        Message 3 of 6 , Mar 31 1:55 PM
        • 0 Attachment
          On Thu, 31 Mar 2005 21:20:38 -0000, Jeff wrote:
          >
          > Basically, open the file Libr_Vols.csv, then open Libr_Scr.csv and
          > TSM_Usage.csv. If the value exists (for example 400002), then do
          > nothing. If it can't be found in either of the two files (Libr_Scr or
          > TSM_Usage) then throw it out to a log file.
          >

          Here's one way. There are many others :-)
          ##################### begin code
          my %seen;
          update_seen("Libr_Scr.csv" );
          update_seen("TSM_Usage.csv");

          my $infile = "Libr_Vols.csv";
          open(IN,"$infile") or die "Couldn't open $infile for reading: $!\n";
          while(<IN>) {
          my $num = (split/,/)[0];
          if (! defined $seen{$num}) {
          print "$num\n";
          }
          }
          close(IN) or die "Couldn't close $infile after reading: $!\n";

          sub update_seen {
          my $infile = shift;
          open(IN,"$infile") or die "Couldn't open $infile for reading: $!\n";
          while(<IN>) {
          ++$seen{(split/,/)[0]};
          }
          close(IN) or die "Couldn't close $infile after reading: $!\n";
          }
          ##################### end code

          Explanations:
          * %seen is first populated with the numbers from the 2 files you want
          to check against the master (the keys hold the numbers, the value is
          not important, as long as it's defined). This is done by the
          update_seen() sub.
          * Now the master is checked. If for any number in the master file,
          there does not exist a defined value in the %seen hash, then that
          number was not found in either of the two files, and is printed to
          STDOUT. If it is defined, nothing is done.
          * (split/,/)[0] splits the current value of $_ (which is the current
          line) on a comma, and returns just the first member of the array that
          split returns - the number, in the case of the files here.

          If anything is unclear, please ask.
          Hope this helps,
          --
          Offer Kaye
        • ateeq
          Folks! I hope everyone is having a merry and wildly fun day!!!! I have a huge collection of hindi film songs(2000 odd) that I need to go through and tag one
          Message 4 of 6 , Mar 31 2:04 PM
          • 0 Attachment
            Folks!
            I hope everyone is having a merry and wildly fun day!!!!
            I have a huge collection of hindi film songs(2000 odd) that I need to
            go through and tag one by one using the itunes interface. Needless to
            say, I am baulking at the prospect{i am lazy}. I know that if I can get
            into the xml file that comes with itunes and make those edits there
            using simple pattern matching, my work can become easier and more
            interesting to boot. However, when I do make changes in the xml (keeping
            itunes closed) , they are lost when I open the application again.

            Has anyone encountered a similar predicament and used PERL to solve it?
            If so, could you point me in the right direction? There are so many
            modules in CPAN called itunes something or other, but I am not really
            getting them{idiot too}.

            I would appreciate some sage advice from the group.

            thanks

            ateeq ahmad
          • Jeff
            WOW!! I was trying to get something done but was at a loss. This is great! Funny... i m sure by the time I would have figured something out, it would have
            Message 5 of 6 , Mar 31 2:06 PM
            • 0 Attachment
              WOW!!

              I was trying to get something done but was at a loss. This is great!
              Funny... i'm sure by the time I would have figured something out, it
              would have been twice as long.. and twice as slow!! haha

              Thanks so much!!!


              --- In perl-beginner@yahoogroups.com, Offer Kaye <offer.kaye@g...> wrote:
              > On Thu, 31 Mar 2005 21:20:38 -0000, Jeff wrote:
              > >
              > > Basically, open the file Libr_Vols.csv, then open Libr_Scr.csv and
              > > TSM_Usage.csv. If the value exists (for example 400002), then do
              > > nothing. If it can't be found in either of the two files (Libr_Scr or
              > > TSM_Usage) then throw it out to a log file.
              > >
              >
              > Here's one way. There are many others :-)
              > ##################### begin code
              > my %seen;
              > update_seen("Libr_Scr.csv" );
              > update_seen("TSM_Usage.csv");
              >
              > my $infile = "Libr_Vols.csv";
              > open(IN,"$infile") or die "Couldn't open $infile for reading: $!\n";
              > while(<IN>) {
              > my $num = (split/,/)[0];
              > if (! defined $seen{$num}) {
              > print "$num\n";
              > }
              > }
              > close(IN) or die "Couldn't close $infile after reading: $!\n";
              >
              > sub update_seen {
              > my $infile = shift;
              > open(IN,"$infile") or die "Couldn't open $infile for reading: $!\n";
              > while(<IN>) {
              > ++$seen{(split/,/)[0]};
              > }
              > close(IN) or die "Couldn't close $infile after reading: $!\n";
              > }
              > ##################### end code
              >
              > Explanations:
              > * %seen is first populated with the numbers from the 2 files you want
              > to check against the master (the keys hold the numbers, the value is
              > not important, as long as it's defined). This is done by the
              > update_seen() sub.
              > * Now the master is checked. If for any number in the master file,
              > there does not exist a defined value in the %seen hash, then that
              > number was not found in either of the two files, and is printed to
              > STDOUT. If it is defined, nothing is done.
              > * (split/,/)[0] splits the current value of $_ (which is the current
              > line) on a comma, and returns just the first member of the array that
              > split returns - the number, in the case of the files here.
              >
              > If anything is unclear, please ask.
              > Hope this helps,
              > --
              > Offer Kaye
            • Jarrod
              It sounds like the XML part of this problem could be made manageable with the Perl module XML::Parser. I am using it for some stuff right now and it is pretty
              Message 6 of 6 , Mar 31 5:38 PM
              • 0 Attachment
                It sounds like the XML part of this problem could be made manageable
                with the Perl module XML::Parser. I am using it for some stuff right now
                and it is pretty nice. In reference to the changes being lost upon the
                opening of iTunes I am not sure what would solve this. For some reason
                locking the file comes to mind. If there isn't a method in one of the
                iTunes modules for doing this outside of flock() I would like to know.
                Hope I was of some help.


                ateeq wrote:

                > Folks!
                > I hope everyone is having a merry and wildly fun day!!!!
                > I have a huge collection of hindi film songs(2000 odd) that I need to
                > go through and tag one by one using the itunes interface. Needless to
                > say, I am baulking at the prospect{i am lazy}. I know that if I can get
                > into the xml file that comes with itunes and make those edits there
                > using simple pattern matching, my work can become easier and more
                > interesting to boot. However, when I do make changes in the xml (keeping
                > itunes closed) , they are lost when I open the application again.
                >
                > Has anyone encountered a similar predicament and used PERL to solve it?
                > If so, could you point me in the right direction? There are so many
                > modules in CPAN called itunes something or other, but I am not really
                > getting them{idiot too}.
                >
                > I would appreciate some sage advice from the group.
                >
                > thanks
                >
                > ateeq ahmad
                >
                >
                >
                >
                > Unsubscribing info is here:
                > http://help.yahoo.com/help/us/groups/groups-32.html
                >
                >
                > ------------------------------------------------------------------------
                > *Yahoo! Groups Links*
                >
                > * To visit your group on the web, go to:
                > http://groups.yahoo.com/group/perl-beginner/
                >
                > * To unsubscribe from this group, send an email to:
                > perl-beginner-unsubscribe@yahoogroups.com
                > <mailto:perl-beginner-unsubscribe@yahoogroups.com?subject=Unsubscribe>
                >
                > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
                > Service <http://docs.yahoo.com/info/terms/>.
                >
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.