How to make an output log file of the zip file you just extracted

How to make an output log file of the zip file you just extracted

Content Index :

How to make an output log file of the zip file you just extracted
Tag : perl , By : Sonal
Date : January 12 2021, 08:33 AM

may help you . Something like this should work. You extract all the files, save the names. Then go through each file looking for errors:
use strict;
use warnings;

use Archive::Zip qw(:ERROR_CODES :CONSTANTS);

my $sSource = "/home/glork/output.zip";
my $sDest = "/home/glork/zipped";

my @extractedFiles;
my $zip = Archive::Zip->new($sSource);
foreach my $member ($zip->members) {
    next if $member->isDirectory;
    (my $extractName = $member->fileName) =~ s{.*/}{};
    push @extractedFiles, $extractName;
    print "Extracted $sDest/$extractName\n";

foreach my $logFile (@extractedFiles) {
    open(LOGFILE, "$sDest/$logFile") or die "can't find file";
    while(<LOGFILE>) {
        print "Error in line $.\n" if(/ERROR/);
    close LOGFILE;

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Windows batch file to iterate over extracted strings from a text file

Tag : string , By : James B
Date : March 29 2020, 07:55 AM
To fix this issue Given a text file file.txt containing
for /f "usebackq tokens=1 delims= " %%a in ("file_path.txt") do echo %%a

Python: Read Pandas Dataframe from csv File, Make Filtered Output to Another File as csv

Tag : python , By : Roel van Dijk
Date : March 29 2020, 07:55 AM
I wish this helpful for you Don't attempt to write each line individually, dataframes have to_csv method.
df = pd.read_csv('input.csv')
# some filtering logic, for example:
filtered_df = df[df['col a'] == 2]

Giving an argument list as file names extracted from another tab separated file

Tag : awk , By : usingtechnology
Date : March 29 2020, 07:55 AM
To fix the issue you can do Going by my understanding of your requirements, you want to use the tab-separated file to get the file names on column 1 and you want to add .txt extension to them and pass it to another file. Firstly use mapfile to get the names from the tab-separated file
mapfile -t fileNames < <(awk -v FS="\t" '{print $1}' tabfile)
awk ... "${fileNames[@]/%/.txt}"

Make new txt file with size info of output and input files separately for each file

Tag : python , By : Ray
Date : March 29 2020, 07:55 AM
this one helps. Use os.path.splitext for remove extension of original files, also f.close() is not necessary, because with automatically close the file:
import glob, os
import pandas as pd

files = glob.glob('*.csv')

#loop by all files
for file in files:
    if not file.startswith(('output_','file_size_')):
        #for write to parameter w
        with open(os.path.splitext(file)[0] + "stats.txt", 'w') as f:
            output_file_name = "output_" + file
            #add both format
            infile = 'SIZE OF INPUT FILE {} IS {}, '.format(file, os.path.getsize(file))
            outfile = 'SIZE OF INPUT FILE {} IS {}'.format(output_file_name, 

import glob, os
import pandas as pd

files = glob.glob('*.csv')

input_all, output_all = 0, 0
#loop by all files
for file in files:
    if not (file.startswith('output_') or file.endswith('stats.txt')):
        with open(os.path.splitext(file)[0] + "stats.txt", 'w') as f:
            output_file_name = "output_" + file
            #add both format
            i = os.path.getsize(file)
            o = os.path.getsize(output_file_name)
            input_all += i
            output_all += o
            infile = 'SIZE OF INPUT FILE {} IS {}, '.format(file, i)
            outfile = 'SIZE OF INPUT FILE {} IS {}'.format(output_file_name, o)


with open("final_stats.txt", 'w') as f:
    instring = 'SIZE OF ALL INPUT FILES IS {}, '.format(input_all)
    outstring = 'SIZE OF ALL OUTPUT FILES IS {}, '.format(output_all)
    both = 'SIZE OF ALL  FILES IS {}'.format(input_all + output_all)

To make a .xls file from the extracted values from a website

Tag : python , By : lewing
Date : March 29 2020, 07:55 AM
may help you . I would consider using pandas and write to csv. You can preserve the language format nicely as well
import requests
from bs4 import BeautifulSoup as bs
import pandas as pd

res = requests.get('https://www.wikipedia.org/')
soup = bs(res.content, 'lxml')
items  = [item.text for item in soup.select('strong')][1:-1]
df = pd.DataFrame(items, columns = ['Languages']) 
df.to_csv(r'C:\Users\User\Desktop\Wiki.csv', sep=',', encoding='utf-8-sig',index = False )
df.to_excel(r"C:\Users\User\Desktop\Wiki.xls", sheet_name='MyData', index = False, header=False) 
Related Posts Related QUESTIONS :
  • How To Avoid a Perl script calling an Another Perl Script
  • Perl - Internal File (create and execute)
  • How can I call a PL/Perl function from another PL/Perl function?
  • How can I terminate a system command with alarm in Perl?
  • When should I use a factory to wrap a constructor in Perl?
  • How can I extract sentences with a particular phrase, in Perl?
  • Dequeue an array in perl with thread::queue
  • How do I tell perl to execute a piece of generated Perl code?
  • Why does a positive lookahead lead to captures in my Perl regex?
  • In a digital photo, how can I detect if a mountain is obscured by clouds?
  • How can I pass a hash to a Perl subroutine?
  • Why do I get 'use: command not found' when I run my Perl script?
  • How can I take a reference to specific hash value in Perl?
  • How do I find the sum of all values from two different arrays in Perl?
  • How can I determine which package my constructor was called from?
  • How do I install Perl's Lingua::Lid?
  • How can I copy a directory but ignore some files in Perl?
  • How can I build something like Amazon S3 in Perl?
  • What does Perl's -p command-line switch do?
  • How can I get the high-res mtime for a symbolic link in Perl?
  • How can I get the ultimate URL without fetching the pages using Perl and LWP?
  • How can I create a new file using a variable value as the name in Perl?
  • Why does my Perl CGI program fail with "Software error: ..."?
  • How can I handle -r=<pattern> with Perl's Getopt::Long?
  • Is there a way that I can force mod_perl to re-use buffer memory?
  • How do I issue an HTTP redirect with Perl's CGI.pm?
  • Can I pass a regex to isa() with Moose-based objects?
  • How can I tell Perl's IO::Socket::INET which interface to use?
  • How do I print a hash structure in Perl?
  • What reasons could there be for converting Perl to Java?
  • Command executed in SSH terminal displays extra line contents
  • Documentation on Serving static files
  • Is Perl cpan's 2.4 Spreadsheet::WriteExcel entirely compatible running code written for its preceding 2.2 version?
  • Command line arguments only work for first element of array
  • Enable a user option to override a value for a variable
  • Assign number to variable in perl subroutine [assign returned list to variables]
  • Comparing three files in Perl
  • Perl - Directory Management on Different Operating Systems
  • Display lines outside multiline comment block
  • Is there a fairly portable and succinct method for parsing an environment variable from a script?
  • Need help understanding how Perl 5 is parsing a compound assignment statement referencing same variable
  • What exactly is happening in this piece of perl code?
  • Tail call Recursion "Optimising"
  • "isn't numeric" error in "sort" after "uniq"
  • Having trouble with the one_of feature in Getopt::Long::Descriptive
  • LWP::UserAgent loses content data when redirecting via POST
  • Bit selection in perl
  • How to use timestamp to get recent files in Perl
  • Perl, How to sort hash (of arrays) keys according to specific positions in arrays
  • Perl How to remove a directory after program finishes
  • Using Mojo::DOM to extract untagged text after heading
  • How do I check if an object is valid when pushed to an ArrayOf[] member in my perl Moo class?
  • Perl: How to deal with a duplicated modules installation?
  • How to print filtered output list of an external command in Perl?
  • Sorting with filehandle perl
  • Why do official perl docker images have two version of perl?
  • How to change markdown fenced block language
  • How to read every single file in a directory using foreach perl
  • Perl: Verifying user input
  • How to automate the LSF waiting based on job name in perl
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com