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, 2020 in Python by Vishal
• 130 points
763 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, 2020 by Kalgi
• 52,350 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, 2020 in Python by Justin
• 140 points

reshown Jun 18, 2020 by Sirajul 765 views
0 votes
1 answer

HI Mr / Mrs I have problem with my jupiter notebook when i try to learn Your video about Machine Learning. Can You help me please ?

Hi@Herlambang, I think you have a 32-bit system. ...READ MORE

answered Dec 18, 2020 in Python by MD
• 95,460 points
750 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,220 points
887 views
+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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 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
2,437 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
• 52,350 points
3,467 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP