| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- """
- 测试代码
- """
- import numpy as np
- from pandas import DataFrame
- from feishu.feishu import Feishu
- from applications.mysql import Mysql
- F = Feishu()
- M = Mysql()
- sql = "SELECT * FROM we_analysis_results where mini_program = '票圈视频+' and date = \'2024-01-15\';"
- if __name__ == '__main__':
- data_lines = M.select(sql)
- L = []
- title_list = []
- for line in data_lines:
- result = [i for i in ([line[3]] + list(line[5:]))]
- L.append(result)
- w = transposed_matrix = np.transpose(L)
- first_row = w[0, :]
- w = w[1:, :]
- non_zero_rows = np.any(w != 0, axis=1)
- w_filtered = w[non_zero_rows]
- my_list = w_filtered.tolist()
- rows = len(my_list)
- datas = [["2024-01-15", "票圈视频+", "", "ab{}".format(i)] + my_list[i] for i in range(rows)]
- F.insert_value(
- sheet_id="gwzBOM",
- values=datas,
- ranges="A2:AH22"
- )
- # # 插入日期
- # F.insert_value(
- # sheet_id="gwzBOM",
- # values=[["2024-01-15", "票圈视频+"] for i in range(rows)],
- # ranges="A2:B22"
- # )
- # titles = [0] + list(first_row)
- # print(titles)
- # DF = DataFrame(w_with_labels, columns=titles)
- # DF.to_excel("test.xlsx", index=False)
|