I have explained my scenario.Please suggest answer for this?

+1 vote
Scenario:I have kept three json files under test folder in s3 bucket and I want to run python script using feed as argument.All the json files contain some random feed names like s2,s3,s4.When I iterate through a s3 bucket with a folder test,I want to read only that json file that contains the feed name passed by the user.

e.g:I have three feed names as s2,s3,s4 in s2.json,s3.json and s4.json file respectively.

when a user executes python upload.py -f s2,then I should be able to read only s2.json containing feed name as s2.Can you please help me with this?
Jan 22 in Python by Vishal
• 130 points
199 views

1 answer to this question.

0 votes

Hi @Vishal,

You can simply use an if-else ladder in such a situation. 

m = sys.argv[]

if m == s2:
    f = open("s2.json", "r")
    print(f.read())

elif m == s3
    f = open("s3.json", "r")
    print(f.read())

elif m == s4
    f = open("s4.json", "r")
    print(f.read())

else:
    print "Invalid Input"
answered Jan 22 by Kalgi
• 51,970 points

Related Questions In Python

0 votes
0 answers

For some reason i cannot click on this element/button and have been trying for hours PLEASE HELP!!

from selenium import webdriver from selenium.webdriver.chrome.options import Options from ...READ MORE

Jun 18 in Python by Justin
• 140 points

reshown Jun 18 by Sirajul 100 views
0 votes
1 answer

I have a code that I want to use alter values between two columns in my dataset

Hi @elvin. I read your script and ...READ MORE

answered Mar 17, 2019 in Python by Omkar
• 69,030 points
85 views
0 votes
0 answers

how do i install django in my system for the project?

can you tell me the procedure for ...READ MORE

May 3, 2019 in Python by Waseem
• 4,540 points
61 views
+2 votes
0 answers
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
729 views
+2 votes
1 answer
+7 votes
8 answers

Difference for string comparison in Python: 'is' vs. ==

If we use "==" means both variables ...READ MORE

answered Sep 3, 2018 in Python by Parul Raheja
623 views
0 votes
1 answer

Can I build a plagiarism checker using python?

Hey @Alessha, you can use an SDK ...READ MORE

answered Aug 5, 2019 in Python by Kalgi
• 51,970 points
1,774 views