tags:

views:

22

answers:

2

Hello all,

Want to read the contents from a .csv file which is in a remote zip file without downloading & extracting the zip file to local machine.

I need this because the file zip file size is too large and downloading it whenever needed takes longer time.

I am trying this in perl.

My code is : my $ftp = Net::FTP::AutoReconnect->new("ftp.somename.com"); $ftp->login("user","password"); $ftp->cwd("path");

my $fh = Net::FTP::RetrHandle->new($ftp,"filename.zip");
my $zip = Archive::Zip->new($fh);
my @member_names = $zip->memberNames();
my $member1 =  $zip->memberNamed("Basic/BoardDescriptions.csv");

my $string = $member1->contents();
print Dumper $string;

I get io::seeking to local header error while calling contents method, till that statement i guess the code is working fine.

Thanks in advance to any one who gives a try to it. Thanks.

A: 

My guess is that this is not Archive::ZIP 's fault .. can you print @member_names ?

It's not obvious how your'e suppose to extract an individual file, although Net::FTP::RetrHandle does promise it:

This was originally designed for use with Archive::Zip; it's reliable enough that the table of contents and individual files can be extracted from a remote ZIP archive without downloading the whole thing.

Try doing the same with another file from another server..

Øyvind Skaar
A: 

Yes i do get member_names.

here is the Dumper of memeber1

$VAR1 = bless( {

             'externalFileName' => bless( {
                                            'sysread_count' => 5,
                                            '_buf' => '\\\\�L3}',
                                            'read_count' => 279,
                                            'size' => 58543590,
                                            'MaxSkipSize' => 2097152,
                                            'ftp' => bless( {
                                                              'ftp' => bless( \*Symbol::GEN0, 'Net::FTP' ),
                                                              '_peer' => 'ftp.site.com',
                                                              'mode' => 'binary',
                                                              'cwd' => '/path',
                                                              '_connect_count' => 1,
                                                              'login' => [
                                                                           'user',
                                                                           'password'
                                                                         ],
                                                              '_args' => {}
                                                            }, 'Net::FTP::AutoReconnect' ),
                                            'curmode' => ':raw',
                                            'filename' => 'Basic.zip',
                                            'nextpos' => 58543590,
                                            'eof' => undef,
                                            'ftp_data' => undef,
                                            'BlockSize' => 10240,
                                            'pos' => 58543590,
                                            'ftp_running' => undef
                                          }, 'Net::FTP::RetrHandle' ),
             'uncompressedSize' => 241661,
             'fileName' => 'Basic/BoardDescriptions.csv',
             'versionNeededToExtract' => 20,
             'fileAttributeFormat' => 0,
             'diskNumberStart' => 0,
             'compressionMethod' => 8,
             'eocdCrc32' => 2053335059,
             'fileComment' => '',
             'externalFileAttributes' => 0,
             'internalFileAttributes' => 0,
             'bitFlag' => 8,
             'lastModFileDateTime' => 1028809846,
             'crc32' => 2053335059,
             'versionMadeBy' => 20,
             'dataEnded' => 1,
             'localExtraField' => '',
             'localHeaderRelativeOffset' => 0,
             'readDataRemaining' => 0,
             'possibleEocdOffset' => 0,
             'desiredCompressionMethod' => 8,
             'compressedSize' => 28891,
             'desiredCompressionLevel' => -1,
             'dataOffset' => 0,
             'fh' => undef,
             'isSymbolicLink' => 0,
             'cdExtraField' => ''
           }, 'Archive::Zip::ZipFileMember' );

i guess the error is at the next statement as i get the object of member1,

In RetrHandle there is a option to set AlreadyBinary flag option, does that create problem , do i need to set that value .

Anyways thanks for investing your time for the query.

Kiran Chaudhary