浏览代码

db_file_reader.py data_cl['Date'] changed

JustDreamer7 2 年之前
父节点
当前提交
4f6651939d
共有 3 个文件被更改,包括 7 次插入7 次删除
  1. 4 4
      file_reader/db_file_reader.py
  2. 1 1
      noSQL_db_Prisma.py
  3. 2 2
      runner.py

+ 4 - 4
file_reader/db_file_reader.py

@@ -22,7 +22,7 @@ class DbFileReader(FileReader):
         """Метод, прочитывающий noSQL БД ПРИЗМА-32 с помощью DB_URL"""
 
         data_cl = pd.DataFrame.from_records(
-            pymongo.MongoClient(self.__db_url)["prisma-32_db"][f'{str(self.single_date)}_12d'].find(
+            pymongo.MongoClient(self.__db_url)["prisma-32_db"][f'{str(self.single_date.date())}_12d'].find(
                 {'cluster': self.cluster}))
         if data_cl.empty:
             raise FileNotFoundError
@@ -37,14 +37,14 @@ class DbFileReader(FileReader):
             data_cl[f'amp{i}'] = amp_dict[f'det_{i:02}']
             data_cl[f'n{i}'] = n_dict[f'det_{i:02}']
         data_cl['time'] = [round(item / 1e9, 2) for item in data_cl['time_ns']]
-        data_cl['Date'] = [datetime.date(item[0:3], item[5:6], item[8:9]) for item in data_cl['time_ns']]
+        data_cl['Date'] = [datetime.date(int(item[0:4]), int(item[5:7]), int(item[8:10])) for item in data_cl['_id']]
 
         return data_cl
 
     def concat_n_data(self, concat_n_df):
-        data_cl = self.reading_db
+        data_cl = self.reading_db()
         # noinspection PyUnresolvedReferences
-        concat_n_df = pd.concat([concat_n_df, data_cl[['Date', 'time', 'trigger'] + self.__class__.__amp_n_cols]],
+        concat_n_df = pd.concat([concat_n_df, data_cl[['Date', 'time', 'trigger'] + DbFileReader.__amp_n_cols]],
                                 ignore_index=True)
         return concat_n_df
 

+ 1 - 1
noSQL_db_Prisma.py

@@ -19,7 +19,7 @@ class NoSQLPrisma:
         self.cluster = cluster
         self.single_date = single_date
         self.file_reader = FileReader(cluster=self.cluster, single_date=self.single_date,
-                                      path_to_files=f'z:\\PRISMA-32\\DataArchive\\DATA P{self.cluster} archive\\data{self.single_date.year}')
+                                      path_to_files=f'D:\\PRISMA20\\P{self.cluster}')
 
     # def __del__(self):
     #     pass

+ 2 - 2
runner.py

@@ -2,8 +2,8 @@ import datetime
 from noSQL_db_Prisma import NoSQLPrisma
 
 
-date_time_start = datetime.date(2022, 9, 29)  # посмотреть почему не собирается конец дня 2018-04-22
-date_time_stop = datetime.date(2022, 9, 29)
+date_time_start = datetime.date(2020, 11, 11)  # посмотреть почему не собирается конец дня 2018-04-22
+date_time_stop = datetime.date(2021, 12, 31)
 # date_time_stop = datetime.date.today()
 LIST_OF_DATES = [(date_time_start + datetime.timedelta(days=i)) for i in
                  range((date_time_stop - date_time_start).days + 1)]