python - How to add any new library like spark-csv in Apache Spark prebuilt version -
i have build spark-csv , able use same pyspark shell using following command
bin/spark-shell --packages com.databricks:spark-csv_2.10:1.0.3
error getting
>>> df_cat.save("k.csv","com.databricks.spark.csv") traceback (most recent call last): file "<stdin>", line 1, in <module> file "/users/abhishekchoudhary/bigdata/cdh5.2.0/spark-1.3.1/python/pyspark/sql/dataframe.py", line 209, in save self._jdf.save(source, jmode, joptions) file "/users/abhishekchoudhary/bigdata/cdh5.2.0/spark-1.3.1/python/lib/py4j-0.8.2.1-src.zip/py4j/java_gateway.py", line 538, in __call__ file "/users/abhishekchoudhary/bigdata/cdh5.2.0/spark-1.3.1/python/lib/py4j-0.8.2.1-src.zip/py4j/protocol.py", line 300, in get_return_value py4j.protocol.py4jjavaerror
where should place jar file in spark pre-built setup able access spark-csv
python editor directly well.
at time used spark-csv, had download commons-csv
jar (not sure still relevant). both jars in spark distribution folder.
i downloaded jars follow:
wget http://search.maven.org/remotecontent?filepath=org/apache/commons/commons-csv/1.1/commons-csv-1.1.jar -o commons-csv-1.1.jar<br/> wget http://search.maven.org/remotecontent?filepath=com/databricks/spark-csv_2.10/1.0.0/spark-csv_2.10-1.0.0.jar -o spark-csv_2.10-1.0.0.jar
then started python spark shell arguments:
./bin/pyspark --jars "spark-csv_2.10-1.0.0.jar,commons-csv-1.1.jar"
and read spark dataframe csv file:
from pyspark.sql import sqlcontext<br/> sqlcontext = sqlcontext(sc)<br/> df = sqlcontext.load(source="com.databricks.spark.csv", path = "/path/to/you/file.csv")<br/> df.show()
Comments
Post a Comment