@@ -100,18 +100,8 @@ async def clear_index_endpoint(
100
100
return {
101
101
"message" : f"All documents in index { index_name } have been successfully cleared"
102
102
}
103
-
104
-
105
- async def csv_row_generator (upload_file ):
106
- df = await run_in_threadpool (pd .read_csv , upload_file .file , delimiter = ";" , decimal = "," , engine = "c" , encoding = "utf-8-sig" )
107
- df = df .replace (np .nan , None )
108
- df = df .rename (lambda x : x .lower (), axis = 'columns' )
109
-
110
- for data in df .to_dict (orient = "records" ):
111
- yield {"_index" : "politicians" , ** data }
112
103
113
104
114
-
115
105
@app .post (
116
106
"/bulk" ,
117
107
response_model = MessageResponse ,
@@ -152,7 +142,14 @@ async def bulk(file: UploadFile = File(...), es: Optional[Search] = Depends(get_
152
142
153
143
return {"message" : "success" }
154
144
155
-
145
+ async def csv_row_generator (upload_file ):
146
+ df = await run_in_threadpool (pd .read_csv , upload_file .file , delimiter = ";" , decimal = "," , engine = "c" , encoding = "utf-8-sig" )
147
+ df = df .replace (np .nan , None )
148
+ df = df .rename (lambda x : x .lower (), axis = 'columns' )
149
+
150
+ for data in df .to_dict (orient = "records" ):
151
+ yield {"_index" : "politicians" , ** data }
152
+
156
153
@app .get (
157
154
"/politicians" ,
158
155
response_model = PoliticiansPaginated ,
0 commit comments