Daily post #13 – I just created a counter using python to track the number of support tickets I do for my company.
This will help me to see a final count by the end of the day. It’ll also show me a timestamp to see when the count was incremented. Here’s the script:
And this is what it it looks like in the output –
I’ve also added a command for exit to end the program. Overall, it’s nothing fancy! But it’s definitely something that’ll help me with my job 🙂
Note: I’m going to Dubai tomorrow for vacation, so I’ll be taking this week off. I will resume my daily posts from 4th of December! 🙂
Daily post #4 – Today I’m going to share how you can use Python code to fetch file names inside a specified directory.
indir = '/users/omkarbhagat/desktop/batman/'
for root, dirs, filenames in os.walk(indir):
for x in filenames:
x = "/users/omkarbhagat/desktop/batman/"+x
Note that the python code above only works with correct indentation so if something breaks, make sure to have correct indentation. Also make sure to have all spaces or all tabs in the code, don’t mix them up!
I had the following setup – A folder called batman on my desktop with couple of txt files inside it. Running the above code returns the following result –
Omkars-MacBook-Pro-3:desktop omkarbhagat$ python test.py
Once I have a file name or directory in a variable, I can do stuff with it. For example, I can change all file names, or edit the content of all these files by a conditional statement or something. I’ll probably share that in a separate post. That’s all for today, thanks for reading! 🙂