-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreader.py
More file actions
28 lines (22 loc) · 938 Bytes
/
reader.py
File metadata and controls
28 lines (22 loc) · 938 Bytes
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
import os
import pandas as pd
import glob2
class ReadFile:
def __init__(self, corpus_path):
self.corpus_path = corpus_path
self.allfiles = glob2.glob(self.corpus_path + "/*/*/*.parquet") + glob2.glob(self.corpus_path + "/*/*.parquet") + glob2.glob(self.corpus_path + "/*.parquet")
self.int=0
self.maxlen=len(self.allfiles)
def readonefile(self,i):
return [(pd.read_parquet(self.allfiles[i], engine="pyarrow")).values.tolist()]
def read_file(self):
"""
This function is reading a parquet file contains several tweets
The file location is given as a string as an input to this function.
:param file_name: string - indicates the path to the file we wish to read.
:return: a dataframe contains tweets.
"""
#full_path = os.path.join(self.corpus_path)
df = self.readonefile(self.int)
self.int+=1
return df