Skip to content

Tag: python-2.7

Getting line number from the exception object

I have defined a custom Exception object and would like to get the line number of the exception. Now, if there is a exception in something() it throws the FlowException but it does not give me the exact line number, How can I get the line number from FlowException(ie; it failed when it executed 2/0)? Here is …

No FileSystem for scheme: s3 with pyspark

I’m trying to read a txt file from S3 with Spark, but I’m getting thhis error: This is my code: This is the full traceback: How can I fix this? Answer If you are using a local machine you can use boto3: (do not forget to setup your AWS S3 credentials). Another clean solution if you are using an AW…

How to replace a word to another word in a list python?

If I have this list: Is it possible to replace every world to any other word without using any auto command, I am thinking about something like this: Answer You can use a list comprehension with an if-else. You now have a new list, list_B, where all instances of the word “world” have been replaced…