modify scripts
This commit is contained in:
@ -92,12 +92,16 @@ def fetch_reports_list_general(fetch_func, table_name, s_date, e_date, data_dir_
|
||||
row['stockName'] = ''
|
||||
if 'stockCode' not in row or row['stockCode'] is None or row['stockCode']=='':
|
||||
row['stockCode'] = ''
|
||||
if 'newPeIssueA' in row:
|
||||
try:
|
||||
row['newPeIssueA'] = float(row.get('newPeIssueA', 0))
|
||||
except ValueError:
|
||||
row['newPeIssueA'] = 0.0
|
||||
|
||||
|
||||
# float 类型的字段,进行转换, 并检查类型是否一致,避免插入数据库失败
|
||||
float_fields = ['newIssuePrice', 'newPeIssueA']
|
||||
for field in float_fields:
|
||||
if field in row:
|
||||
try:
|
||||
row[field] = float(row.get(field, 0))
|
||||
except (ValueError, TypeError):
|
||||
row[field] = 0.0
|
||||
|
||||
# 对超长的 author 和 researcher 字段进行截断,避免数据库插入失败, 最大长度为250个字符
|
||||
if 'author' in row and row['author'] is not None:
|
||||
if len(row['author']) > 250:
|
||||
|
||||
Reference in New Issue
Block a user