Datasets:
parquet-converter
commited on
Commit
•
ca21bb5
1
Parent(s):
28ce7f8
Update parquet files
Browse files- .gitattributes +1 -0
- .gitignore +0 -4
- data.csv +0 -0
- default/train/0000.parquet +3 -0
- src/ingestion.py +0 -40
.gitattributes
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
default/train/0000.parquet filter=lfs diff=lfs merge=lfs -text
|
.gitignore
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
.env
|
2 |
-
venv/
|
3 |
-
ongoing/
|
4 |
-
*.ipynb
|
|
|
|
|
|
|
|
|
|
data.csv
DELETED
The diff for this file is too large to render.
See raw diff
|
|
default/train/0000.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a6cc968efb260b716d1b4836c0e3d2ac9d7a5cd776298863a73c877de1a9bff9
|
3 |
+
size 1784263
|
src/ingestion.py
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import tqdm
|
3 |
-
import csv
|
4 |
-
import pandas as pd
|
5 |
-
|
6 |
-
|
7 |
-
def get_darija_values(file):
|
8 |
-
"""This function reads the darija column from a csv file and returns
|
9 |
-
a generator of the values in the column.
|
10 |
-
"""
|
11 |
-
with open(file, 'r', encoding='utf-8') as infile:
|
12 |
-
reader = csv.reader(infile)
|
13 |
-
headers = next(reader)
|
14 |
-
for i, col in enumerate(headers):
|
15 |
-
if col=='darija':
|
16 |
-
break
|
17 |
-
for row in reader:
|
18 |
-
if row[i] != "":
|
19 |
-
yield row[i]
|
20 |
-
|
21 |
-
|
22 |
-
def ingest(input_data_path="ongoing/", output_data_path="data.csv"):
|
23 |
-
"""This function reads all the csv files in the input_data_path and extracts the
|
24 |
-
darija column from each file. It then saves the darija column in a csv file.
|
25 |
-
"""
|
26 |
-
full_df = pd.DataFrame()
|
27 |
-
text_list = []
|
28 |
-
|
29 |
-
for file in tqdm.tqdm(os.listdir(input_data_path)):
|
30 |
-
if file.endswith(".csv"):
|
31 |
-
darija_txt = list(get_darija_values(input_data_path + file))
|
32 |
-
text_list.extend(darija_txt)
|
33 |
-
full_df = pd.concat([full_df, pd.DataFrame(darija_txt, columns=["darija"])])
|
34 |
-
|
35 |
-
full_df.to_csv(output_data_path, index=False)
|
36 |
-
print("Ingestion complete")
|
37 |
-
|
38 |
-
|
39 |
-
if __name__ == "__main__":
|
40 |
-
ingest("ongoing/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|