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

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")

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

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

    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 190 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,220 points
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,150 points
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
+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
+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
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