title: Pyspark: how to read a .csv file in google bucket?
body: <p>I have some files stored in a google bucket. Those are my settings as suggested <a href="https://stackoverflow.com/questions/55595263/pyspark-error-java-io-ioexception-no-filesystem-for-scheme-gs">here</a>.</p>
  
  <pre><code>spark = SparkSession.builder.\
          master("local[*]").\
          appName("TestApp").\
          config("spark.serializer", KryoSerializer.getName).\
          config("spark.jars", "/usr/local/.sdkman/candidates/spark/2.4.4/jars/gcs-connector-hadoop2-2.1.1.jar").\
          config("spark.kryo.registrator", GeoSparkKryoRegistrator.getName).\
          getOrCreate()
  #Recommended settings for using GeoSpark
  spark.conf.set("spark.driver.memory", 6)
  spark.conf.set("spark.network.timeout", 1000)
  #spark.conf.set("spark.driver.maxResultSize", 5)
  spark.conf.set
  
  spark._jsc.hadoopConfiguration().set('fs.gs.impl', 'com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem')
  # This is required if you are using service account and set true, 
  spark._jsc.hadoopConfiguration().set('fs.gs.auth.service.account.enable', 'false')
  spark._jsc.hadoopConfiguration().set('google.cloud.auth.service.account.json.keyfile', "myJson.json")
  
  
  
  path = 'mBucket-c892b51f8579.json'
  os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = path
  client = storage.Client()
  name = 'https://console.cloud.google.com/storage/browser/myBucket/'
  bucket_id = 'myBucket'
  bucket = client.get_bucket(bucket_id)
  </code></pre>
  
  <p>I can read them simple using the following:</p>
  
  <pre><code>df = pd.read_csv('gs://myBucket/myFile.csv.gz', compression='gzip')
  df.head()
  
      time_zone_name           province_short
  0   America/Chicago              US.TX
  1   America/Chicago              US.TX
  2   America/Los_Angeles          US.CA
  3   America/Chicago              US.TX
  4   America/Los_Angeles          US.CA
  </code></pre>
  
  <p>I am trying to read the same file with <code>pyspark</code></p>
  
  <pre><code>myTable = spark.read.format("csv").schema(schema).load('gs://myBucket/myFile.csv.gz', compression='gzip')
  </code></pre>
  
  <p>but I get the following error</p>
  
  <pre><code>Py4JJavaError: An error occurred while calling o257.load.
  : java.lang.NoClassDefFoundError: Could not initialize class com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(Configuration.java:2134)
      at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2099)
      at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2193)
      at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2654)
      at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667)
      at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:94)
      at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2703)
      at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2685)
      at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:373)
      at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295)
      at org.apache.spark.sql.execution.streaming.FileStreamSink$.hasMetadata(FileStreamSink.scala:45)
      at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:332)
      at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:223)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:211)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:178)
      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:498)
      at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
      at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
      at py4j.Gateway.invoke(Gateway.java:282)
      at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
      at py4j.commands.CallCommand.execute(CallCommand.java:79)
      at py4j.GatewayConnection.run(GatewayConnection.java:238)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>