当前位置:网站首页>spark read local file
spark read local file
2022-08-02 07:50:00 【this is a book】
1 Background
Based on spark development program
The data is placed in a local file in text format
The language case of this article is java
2 steps
2.1 Construction Project
build a spark project based on maven _this is a book blog-CSDN blog
2.2 Code Example
SparkConf conf = new SparkConf().setAppName("demo").setMaster("local[*]");SparkSession sparkSession = SparkSession.builder().config(conf).getOrCreate();JavaSparkContext javaSparkContext = new JavaSparkContext(sparkSession.sparkContext());JavaRDD rdd = javaSparkContext.textFile(INPUT_PATH);rdd.foreach(new VoidFunction() {@Overridepublic void call(String s) throws Exception {System.out.println(s);}}); 3 Notes
If it is placed on a linux server and running on spark, the file path needs to be prefixed with this
file:///data/demo.textThe reason is that spark is generally used in combination with hdms, and a prefix needs to be added to read a local file to indicate that a local file is read
边栏推荐
猜你喜欢

Splunk Filed Alias field name

MySQL-FlinkCDC-Hudi实时入湖

张驰课堂:六西格玛培训工具——箱线图

Splunk Field Caculated 计算字段
![带手续费买卖股票的最大利益[找DP的状态定义到底缺什么?]](/img/14/cd6ed7452230571db2e027f61dbdba.png)
带手续费买卖股票的最大利益[找DP的状态定义到底缺什么?]
![The best interests of buying and selling stocks with handling fees [What is missing in the definition of DP status?]](/img/14/cd6ed7452230571db2e027f61dbdba.png)
The best interests of buying and selling stocks with handling fees [What is missing in the definition of DP status?]

Neural network

吃透Chisel语言.31.Chisel进阶之通信状态机(三)——Ready-Valid接口:定义、时序和Chisel中的实现

MySQL-数据库事务详解

MySQL-基础
随机推荐
【机器学习】实验1布置:基于决策树的英雄联盟游戏胜负预测
59:第五章:开发admin管理服务:12:MongoDB的使用场景;(非核心数据,数据量比较大的非核心数据,人脸照片等隐私的小文件;)
Splunk Filed extraction field interception
【心电信号】基于matlab心率检测【含Matlab源码 1993期】
21 days learning challenge 】 【 sequential search
Modify apt-get source to domestic mirror source
spark读取文件夹数据
Link with Game Glitch
MySQL报错1055解决办法:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains
【ROS基础】map、odom、base_link、laser 的理解 及其 tf 树的理解
敏捷、DevOps和嵌入式系统测试
LeetCode 283. Shifting Zeros (Simple, Array)
在VMware上安装Metasploitable2
spark架构
MySQL - slow query log
使用hutool做本地缓存的工具类
有趣的网站
2022夏暑假每日一题(六)
sql 远程访问链接服务器
条件构造器~wapper