Python nested `if else` statements are returning errorsReplacements for switch statement in Python?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?

What is a scalar particle?

How to move a paragraph and paste it without an initial newline first

What techniques can I use to seduce a PC without arousing suspicion of ulterior motives?

Is it good to put X-Robots-Tag for 410 pages which are still in Google's Index?

Paint numbers from 1 to 8 with two colours

For which would you expect the liquidity on instrument X to be the greatest: its spot, future, option or swap?

Why don't we say a blessing before giving charity?

Why is more music written in sharp keys than flat keys?

What can I use for input conversion instead of scanf?

How short does a trip need to be before flying is less safe than other forms of transportation?

Sci-fi book trilogy about space travel & 'jacking'

How could a sequence of random dates be generated, given year interval?

When to use 8va in musical notation?

Is the ''yoi'' meaning ''ready'' when doing karate the same as the ''yoi'' which means nice/good?

How do I figure out how many hydrogens my compound actually has using a mass and NMR spectrum?

How can an immortal member of the nobility be prevented from taking the throne?

How does kinetic energy work in braking a vehicle?

Why does the Joker do this to Bob?

Why are so many cities in the list of 50 most violent cities in the world located in South and Central America?

Scrum Team and Product Owner working against each other

Why does Bane's stock exchange robbery actually work to bankrupt Bruce Wayne?

What elements would be created in a star composed entirely of gold?

What's the most profitable use for an elemental transmuter?

Why does the SR-71 Blackbird sometimes have dents in the nose?



Python nested `if else` statements are returning errors


Replacements for switch statement in Python?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









1

















I am trying to read .txt and .log files, search for specific words and return results to a CSV using if statements. How do I open other files to read in if statements?



I ran the part that's giving me the errors on another python file and it worked fine and was able to open and read. So it's not the code itself I don't think. Although I'm fairly new to Python.



When running the below I get the following error.




latest_file = max(list_of_files, key=os.path.getctime)
ValueError: max() arg is an empty sequence"




with open('//' + hostName + '/C$/Windows/System32/inetsrv/config/applicationHost.config') as doc:
lines1 = doc.read()
if ("logFormat=" + '"W3C"' in lines1):
list_of_files = glob.glob('//' + hostName + '/C$/inetpub/logs/LogFiles/W3SVC1/*')
latest_file = max(list_of_files, key=os.path.getctime)
y = latest_file
with open(y) as doc1:









share|improve this question























  • 5





    the error is telling you that list_of_files has no items, double check that your path to the files is constructed properly

    – aws_apprentice
    Mar 28 at 17:07






  • 1





    When I used glob.glob, I remmember it was only a list of filenames, I had to concatenate path+file to open them, probably you have the same problem. Debug is your new best friend

    – Wonka
    Mar 28 at 17:15

















1

















I am trying to read .txt and .log files, search for specific words and return results to a CSV using if statements. How do I open other files to read in if statements?



I ran the part that's giving me the errors on another python file and it worked fine and was able to open and read. So it's not the code itself I don't think. Although I'm fairly new to Python.



When running the below I get the following error.




latest_file = max(list_of_files, key=os.path.getctime)
ValueError: max() arg is an empty sequence"




with open('//' + hostName + '/C$/Windows/System32/inetsrv/config/applicationHost.config') as doc:
lines1 = doc.read()
if ("logFormat=" + '"W3C"' in lines1):
list_of_files = glob.glob('//' + hostName + '/C$/inetpub/logs/LogFiles/W3SVC1/*')
latest_file = max(list_of_files, key=os.path.getctime)
y = latest_file
with open(y) as doc1:









share|improve this question























  • 5





    the error is telling you that list_of_files has no items, double check that your path to the files is constructed properly

    – aws_apprentice
    Mar 28 at 17:07






  • 1





    When I used glob.glob, I remmember it was only a list of filenames, I had to concatenate path+file to open them, probably you have the same problem. Debug is your new best friend

    – Wonka
    Mar 28 at 17:15













1












1








1


0






I am trying to read .txt and .log files, search for specific words and return results to a CSV using if statements. How do I open other files to read in if statements?



I ran the part that's giving me the errors on another python file and it worked fine and was able to open and read. So it's not the code itself I don't think. Although I'm fairly new to Python.



When running the below I get the following error.




latest_file = max(list_of_files, key=os.path.getctime)
ValueError: max() arg is an empty sequence"




with open('//' + hostName + '/C$/Windows/System32/inetsrv/config/applicationHost.config') as doc:
lines1 = doc.read()
if ("logFormat=" + '"W3C"' in lines1):
list_of_files = glob.glob('//' + hostName + '/C$/inetpub/logs/LogFiles/W3SVC1/*')
latest_file = max(list_of_files, key=os.path.getctime)
y = latest_file
with open(y) as doc1:









share|improve this question

















I am trying to read .txt and .log files, search for specific words and return results to a CSV using if statements. How do I open other files to read in if statements?



I ran the part that's giving me the errors on another python file and it worked fine and was able to open and read. So it's not the code itself I don't think. Although I'm fairly new to Python.



When running the below I get the following error.




latest_file = max(list_of_files, key=os.path.getctime)
ValueError: max() arg is an empty sequence"




with open('//' + hostName + '/C$/Windows/System32/inetsrv/config/applicationHost.config') as doc:
lines1 = doc.read()
if ("logFormat=" + '"W3C"' in lines1):
list_of_files = glob.glob('//' + hostName + '/C$/inetpub/logs/LogFiles/W3SVC1/*')
latest_file = max(list_of_files, key=os.path.getctime)
y = latest_file
with open(y) as doc1:






python






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 17:37









Shakespear

1,0873 gold badges14 silver badges21 bronze badges




1,0873 gold badges14 silver badges21 bronze badges










asked Mar 28 at 17:05









J TJ T

221 silver badge6 bronze badges




221 silver badge6 bronze badges










  • 5





    the error is telling you that list_of_files has no items, double check that your path to the files is constructed properly

    – aws_apprentice
    Mar 28 at 17:07






  • 1





    When I used glob.glob, I remmember it was only a list of filenames, I had to concatenate path+file to open them, probably you have the same problem. Debug is your new best friend

    – Wonka
    Mar 28 at 17:15












  • 5





    the error is telling you that list_of_files has no items, double check that your path to the files is constructed properly

    – aws_apprentice
    Mar 28 at 17:07






  • 1





    When I used glob.glob, I remmember it was only a list of filenames, I had to concatenate path+file to open them, probably you have the same problem. Debug is your new best friend

    – Wonka
    Mar 28 at 17:15







5




5





the error is telling you that list_of_files has no items, double check that your path to the files is constructed properly

– aws_apprentice
Mar 28 at 17:07





the error is telling you that list_of_files has no items, double check that your path to the files is constructed properly

– aws_apprentice
Mar 28 at 17:07




1




1





When I used glob.glob, I remmember it was only a list of filenames, I had to concatenate path+file to open them, probably you have the same problem. Debug is your new best friend

– Wonka
Mar 28 at 17:15





When I used glob.glob, I remmember it was only a list of filenames, I had to concatenate path+file to open them, probably you have the same problem. Debug is your new best friend

– Wonka
Mar 28 at 17:15












1 Answer
1






active

oldest

votes


















0


















Apparently it was working for most hostnames. I added the try and except statements and caught the errors.






share|improve this answer



























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403254%2fpython-nested-if-else-statements-are-returning-errors%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown


























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0


















    Apparently it was working for most hostnames. I added the try and except statements and caught the errors.






    share|improve this answer






























      0


















      Apparently it was working for most hostnames. I added the try and except statements and caught the errors.






      share|improve this answer




























        0














        0










        0









        Apparently it was working for most hostnames. I added the try and except statements and caught the errors.






        share|improve this answer














        Apparently it was working for most hostnames. I added the try and except statements and caught the errors.







        share|improve this answer













        share|improve this answer




        share|improve this answer










        answered Mar 28 at 21:38









        J TJ T

        221 silver badge6 bronze badges




        221 silver badge6 bronze badges

































            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403254%2fpython-nested-if-else-statements-are-returning-errors%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown









            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현