notes/snippet/python/attr.py

34 lines
915 B
Python

# coding=utf-8
"""
file example:
1 name 名称 String 否 40 字典信息
"""
import argparse
import pandas as pd
def main(file_path):
df = pd.read_csv(file_path, header=None, sep=' ', keep_default_na=False)
for i,row in df.iterrows():
print("/**")
comment = "字段说明: {}, 编号: {}, 可空: {}, 长度: {}, 字典: {}".format(row[2],row[0],row[4],row[5],row[6])
print(" * {}".format(comment))
print(" */")
print("@ApiModelProperty(value = \"{}\")".format(comment))
print("private {} {};\n".format(row[3],row[1]))
if __name__ == '__main__':
help_msg = """
example: python attr.py --file=/path/to/data.csv --table_name=table
"""
parser = argparse.ArgumentParser(description=help_msg)
parser.add_argument('--file', type=str, help='Input csv file')
args = parser.parse_args()
csv_file = args.file
main(csv_file)