Search
 
SCRIPT & CODE EXAMPLE
 

SQL

import sheets doc into databricks

%scala
import scala.sys.process._

// Choose a name for your resulting table in Databricks
var tableName = "user_mapping"

// Replace this URL with the one from your Google Spreadsheets
// Click on File --> Publish to the Web --> Option CSV and copy the URL
var url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vRkLRx_GDKr1AN0hdhPlqkfwEZXPLAyRz9j-t9oRcsYdusI0Id4zD8TX9PbsSTnTsirDQDK3sfHwpGu/pub?output=csv"

var localpath = "/tmp/" + tableName + ".csv"
dbutils.fs.rm("file:" + localpath)
"wget -O " + localpath + " " + url !!

dbutils.fs.mkdirs("dbfs:/datasets/gsheets")
dbutils.fs.cp("file:" + localpath, "dbfs:/datasets/gsheets")

sqlContext.sql("drop table if exists " + tableName)
var df = spark.read.option("header", "true").option("inferSchema", "true").csv("/datasets/gsheets/" + tableName + ".csv");

df.write.saveAsTable(tableName);
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql convert charset 
Sql :: simple plsql program run in oracle sql developer but got the error 
Sql :: intellij idea add mysql connector 
Sql :: mostrar datos de tablas relacionadas mysql kjava 
Sql :: sqlc yml settings version 1.14 
Sql :: get all employees if name ends with in sql 
Sql :: mysql phpmyadmin mysqli_construct:: error for mac user 
Sql :: deny select insert update delete sql 
Sql :: extract domain name from email id mariadb 
Sql :: Laravel SQLSTATE[HY093] with array query 
Sql :: check records older than 10 days 
Sql :: codeigniter 3 get best-selling products 
Sql :: lesser than or equal to symbol in postgres 
Sql :: Inner join steps 
Sql :: != not working in mysql 
Sql :: export partttion and import in oracle 
Sql :: [] Wildcard in SQL 
Sql :: mysql auto increment jumping 
Sql :: Which MySQL statement is used to delete data from a database 
Sql :: SQL LEFT JOIN With AS Alias 
Sql :: Grant All Priveleges On All Databases 
Sql :: django mysqlclient connection string 
Sql :: python mysql github 
Sql :: concatenate text from multiple rows into a single text stringin SQL Server 
Sql :: opensuse stop MySQL 
Sql :: how to change the field size of an existing column 
Sql :: best practive to pass multiple table to stored procedure in sql server 
Sql :: jooq replace 
Sql :: ora 00001 in oracle 
Sql :: subquery in Insert 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =