src.pipeline.reader

 1def read_parquet(spark, path):
 2    """Lit un fichier Parquet"""
 3    return spark.read.parquet(path)
 4
 5
 6def lire_csv(spark, path, header=True, inferSchema=True, sep=","):
 7    """Lit un fichier CSV"""
 8    return spark.read.csv(path, header=header, inferSchema=inferSchema, sep=sep)
 9
10
11def lire_table_sql(spark, table_name):
12    """Lit une table Spark SQL"""
13    return spark.read.table(table_name)
14
15
16def lire_jdbc(spark, url, table, properties):
17    """Lit une table via JDBC"""
18    return spark.read.jdbc(url=url, table=table, properties=properties)
19
20
21def lire_json(spark, path, multiLine=True):
22    """Lit un fichier JSON"""
23    return spark.read.json(path, multiLine=multiLine)
24
25
26def lire_text(spark, path):
27    """Lit un fichier texte brut"""
28    return spark.read.text(path)
29
30
31def lire_xml(spark, path, rowTag):
32    """Lit un fichier XML (nécessite spark-xml)"""
33    return spark.read.format("xml").option("rowTag", rowTag).load(path)
34
35
36def lire_avro(spark, path):
37    """Lit un fichier Avro"""
38    return spark.read.format("avro").load(path)
39
40
41def lire_delta(spark, path):
42    """Lit un fichier Delta Lake"""
43    return spark.read.format("delta").load(path)
def read_parquet(spark, path):
2def read_parquet(spark, path):
3    """Lit un fichier Parquet"""
4    return spark.read.parquet(path)

Lit un fichier Parquet

def lire_csv(spark, path, header=True, inferSchema=True, sep=','):
7def lire_csv(spark, path, header=True, inferSchema=True, sep=","):
8    """Lit un fichier CSV"""
9    return spark.read.csv(path, header=header, inferSchema=inferSchema, sep=sep)

Lit un fichier CSV

def lire_table_sql(spark, table_name):
12def lire_table_sql(spark, table_name):
13    """Lit une table Spark SQL"""
14    return spark.read.table(table_name)

Lit une table Spark SQL

def lire_jdbc(spark, url, table, properties):
17def lire_jdbc(spark, url, table, properties):
18    """Lit une table via JDBC"""
19    return spark.read.jdbc(url=url, table=table, properties=properties)

Lit une table via JDBC

def lire_json(spark, path, multiLine=True):
22def lire_json(spark, path, multiLine=True):
23    """Lit un fichier JSON"""
24    return spark.read.json(path, multiLine=multiLine)

Lit un fichier JSON

def lire_text(spark, path):
27def lire_text(spark, path):
28    """Lit un fichier texte brut"""
29    return spark.read.text(path)

Lit un fichier texte brut

def lire_xml(spark, path, rowTag):
32def lire_xml(spark, path, rowTag):
33    """Lit un fichier XML (nécessite spark-xml)"""
34    return spark.read.format("xml").option("rowTag", rowTag).load(path)

Lit un fichier XML (nécessite spark-xml)

def lire_avro(spark, path):
37def lire_avro(spark, path):
38    """Lit un fichier Avro"""
39    return spark.read.format("avro").load(path)

Lit un fichier Avro

def lire_delta(spark, path):
42def lire_delta(spark, path):
43    """Lit un fichier Delta Lake"""
44    return spark.read.format("delta").load(path)

Lit un fichier Delta Lake