티스토리 뷰
pyspark에서 스파크세션을 이용하여 CSV파일을 읽어서 데이터프레임을 생성하는 예제를 알아보겠습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark.sql.types import StructType, StructField, StringType | |
schema = StructType([ | |
StructField("age", StringType(), True), | |
StructField("height", StringType(), True), | |
StructField("name", StringType(), True)]) | |
# spark = SparkSession | |
# 스키마 지정 안함 | |
spark.read.csv("/user/shs/sample.csv").show() | |
# 스키마 지정하고 읽음 | |
spark.read.csv("/user/shs/sample.csv", header=False, schema=schema).show() |
반응형
'빅데이터 > spark' 카테고리의 다른 글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- mysql
- 오류
- HIVE
- 다이나믹
- 백준
- AWS
- java
- bash
- SPARK
- Tez
- 파이썬
- Linux
- yarn
- Python
- S3
- emr
- build
- nodejs
- oozie
- error
- SQL
- airflow
- 정올
- Hadoop
- 하이브
- ubuntu
- HDFS
- hbase
- 하둡
- 알고리즘
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함