List index out of range error

Hello,
I am trying to create a RDD from accounts data and parse user id, first and last names. And trying to print the resulting RDD output. But, I just get error message that the list index is out of range. xI am attaching my sample code, error message below. Has anyone resolved this one before?
Thanks!

accountsByID = sc.textFile("/loudacre/accounts/*")
…: .map(lambda s: s.split(’,’))
…: .map(lambda values: (values[0],values[4] + ‘,’ + values[3]))

for i in accountsByID.take(5):
…: print(i)
…:
17/05/25 15:13:29 INFO mapred.FileInputFormat: Total input paths to process : 4
17/05/25 15:13:29 INFO spark.SparkContext: Starting job: runJob at PythonRDD.scala:393
17/05/25 15:13:29 INFO scheduler.DAGScheduler: Got job 0 (runJob at PythonRDD.scala:393) with 1 output partitions
17/05/25 15:13:29 INFO scheduler.DAGScheduler: Final stage: ResultStage 0 (runJob at PythonRDD.scala:393)
17/05/25 15:13:29 INFO scheduler.DAGScheduler: Parents of final stage: List()
17/05/25 15:13:29 INFO scheduler.DAGScheduler: Missing parents: List()
17/05/25 15:13:29 INFO scheduler.DAGScheduler: Submitting ResultStage 0 (PythonRDD[2] at RDD at PythonRDD.scala:43), which has no missing parents
17/05/25 15:13:29 INFO storage.MemoryStore: Block broadcast_1 stored as values in memory (estimated size 5.4 KB, free 260.8 KB)
17/05/25 15:13:29 INFO storage.MemoryStore: Block broadcast_1_piece0 stored as bytes in memory (estimated size 3.5 KB, free 264.3 KB)
17/05/25 15:13:29 INFO storage.BlockManagerInfo: Added broadcast_1_piece0 in memory on localhost:48590 (size: 3.5 KB, free: 208.8 MB)
17/05/25 15:13:29 INFO spark.SparkContext: Created broadcast 1 from broadcast at DAGScheduler.scala:1006
17/05/25 15:13:29 INFO scheduler.DAGScheduler: Submitting 1 missing tasks from ResultStage 0 (PythonRDD[2] at RDD at PythonRDD.scala:43)
17/05/25 15:13:29 INFO scheduler.TaskSchedulerImpl: Adding task set 0.0 with 1 tasks
17/05/25 15:13:29 INFO scheduler.TaskSetManager: Starting task 0.0 in stage 0.0 (TID 0, localhost, partition 0,PROCESS_LOCAL, 2154 bytes)
17/05/25 15:13:29 INFO executor.Executor: Running task 0.0 in stage 0.0 (TID 0)
17/05/25 15:13:29 INFO rdd.HadoopRDD: Input split: hdfs://localhost:8020/loudacre/accounts/part-m-00000:0+4746913
17/05/25 15:13:29 INFO Configuration.deprecation: mapred.tip.id is deprecated. Instead, use mapreduce.task.id
17/05/25 15:13:29 INFO Configuration.deprecation: mapred.task.id is deprecated. Instead, use mapreduce.task.attempt.id
17/05/25 15:13:29 INFO Configuration.deprecation: mapred.task.is.map is deprecated. Instead, use mapreduce.task.ismap
17/05/25 15:13:29 INFO Configuration.deprecation: mapred.task.partition is deprecated. Instead, use mapreduce.task.partition
17/05/25 15:13:29 INFO Configuration.deprecation: mapred.job.id is deprecated. Instead, use mapreduce.job.id
17/05/25 15:13:30 ERROR executor.Executor: Exception in task 0.0 in stage 0.0 (TID 0)
org.apache.spark.api.python.PythonException: Traceback (most recent call last):
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/worker.py”, line 111, in main
process()
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/worker.py”, line 106, in process
serializer.dump_stream(func(split_index, iterator), outfile)
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/serializers.py”, line 263, in dump_stream
vs = list(itertools.islice(iterator, batch))
File “/usr/lib/spark/python/pyspark/rdd.py”, line 1293, in takeUpToNumLeft
yield next(iterator)
File “”, line 1, in
IndexError: list index out of range

at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
at org.apache.spark.scheduler.Task.run(Task.scala:89)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

17/05/25 15:13:30 WARN scheduler.TaskSetManager: Lost task 0.0 in stage 0.0 (TID 0, localhost): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/worker.py”, line 111, in main
process()
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/worker.py”, line 106, in process
serializer.dump_stream(func(split_index, iterator), outfile)
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/serializers.py”, line 263, in dump_stream
vs = list(itertools.islice(iterator, batch))
File “/usr/lib/spark/python/pyspark/rdd.py”, line 1293, in takeUpToNumLeft
yield next(iterator)
File “”, line 1, in
IndexError: list index out of range

at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
at org.apache.spark.scheduler.Task.run(Task.scala:89)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

17/05/25 15:13:30 ERROR scheduler.TaskSetManager: Task 0 in stage 0.0 failed 1 times; aborting job
17/05/25 15:13:30 INFO scheduler.TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool
17/05/25 15:13:30 INFO scheduler.TaskSchedulerImpl: Cancelling stage 0
17/05/25 15:13:30 INFO scheduler.DAGScheduler: ResultStage 0 (runJob at PythonRDD.scala:393) failed in 0.472 s
17/05/25 15:13:30 INFO scheduler.DAGScheduler: Job 0 failed: runJob at PythonRDD.scala:393, took 0.670128 s

Py4JJavaError Traceback (most recent call last)
in ()
----> 1 for i in accountsByID.take(5):
2 print(i)
3

/usr/lib/spark/python/pyspark/rdd.py in take(self, num)
1295
1296 p = range(partsScanned, min(partsScanned + numPartsToTry, totalParts))
-> 1297 res = self.context.runJob(self, takeUpToNumLeft, p)
1298
1299 items += res

/usr/lib/spark/python/pyspark/context.py in runJob(self, rdd, partitionFunc, partitions, allowLocal)
937 # SparkContext#runJob.
938 mappedRDD = rdd.mapPartitions(partitionFunc)
–> 939 port = self._jvm.PythonRDD.runJob(self._jsc.sc(), mappedRDD._jrdd, partitions)
940 return list(_load_from_socket(port, mappedRDD._jrdd_deserializer))
941

/usr/lib/spark/python/lib/py4j-0.9-src.zip/py4j/java_gateway.py in call(self, *args)
811 answer = self.gateway_client.send_command(command)
812 return_value = get_return_value(
–> 813 answer, self.gateway_client, self.target_id, self.name)
814
815 for temp_arg in temp_args:

/usr/lib/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
43 def deco(*a, **kw):
44 try:
—> 45 return f(*a, **kw)
46 except py4j.protocol.Py4JJavaError as e:
47 s = e.java_exception.toString()

/usr/lib/spark/python/lib/py4j-0.9-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
306 raise Py4JJavaError(
307 “An error occurred while calling {0}{1}{2}.\n”.
–> 308 format(target_id, “.”, name), value)
309 else:
310 raise Py4JError(

Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.runJob.
: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 0.0 failed 1 times, most recent failure: Lost task 0.0 in stage 0.0 (TID 0, localhost): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/worker.py”, line 111, in main
process()
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/worker.py”, line 106, in process
serializer.dump_stream(func(split_index, iterator), outfile)
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/serializers.py”, line 263, in dump_stream
vs = list(itertools.islice(iterator, batch))
File “/usr/lib/spark/python/pyspark/rdd.py”, line 1293, in takeUpToNumLeft
yield next(iterator)
File “”, line 1, in
IndexError: list index out of range

at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
at org.apache.spark.scheduler.Task.run(Task.scala:89)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Driver stacktrace:
at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1431)
at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1419)
at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1418)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1418)
at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:799)
at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:799)
at scala.Option.foreach(Option.scala:236)
at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:799)
at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:1640)
at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1599)
at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1588)
at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)
at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:620)
at org.apache.spark.SparkContext.runJob(SparkContext.scala:1843)
at org.apache.spark.SparkContext.runJob(SparkContext.scala:1856)
at org.apache.spark.SparkContext.runJob(SparkContext.scala:1869)
at org.apache.spark.api.python.PythonRDD$.runJob(PythonRDD.scala:393)
at org.apache.spark.api.python.PythonRDD.runJob(PythonRDD.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:381)
at py4j.Gateway.invoke(Gateway.java:259)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:209)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.spark.api.python.PythonException: Traceback (most recent call last):
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/worker.py”, line 111, in main
process()
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/worker.py”, line 106, in process
serializer.dump_stream(func(split_index, iterator), outfile)
File “/usr/lib/spark/python/lib/pyspark.zip/pyspark/serializers.py”, line 263, in dump_stream
vs = list(itertools.islice(iterator, batch))
File “/usr/lib/spark/python/pyspark/rdd.py”, line 1293, in takeUpToNumLeft
yield next(iterator)
File “”, line 1, in
IndexError: list index out of range

at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
at org.apache.spark.scheduler.Task.run(Task.scala:89)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
... 1 more