2017-09-25 42 views

回答

0

似乎很難直接在SPSS中完成。 一個可能的答案:使用python + pandas。

import pandas as pd 

def add_leading_zero_to_csv(path_to_csv_file): 
    # open the file 
    df_csv = pd.read_csv(path_to_csv_file) 
    # you can possibly specify the format of a column if needed 
    df_csv['specific_column'] = df_csv['specific_column'].map(lambda x: '%.2f' % x) 
    # save the file (with a precision of 3 for all the floats) 
    df_csv.to_csv(path_to_csv_file, index=False, float_format='%.3g') 

有關「g」格式的更多信息:Format Specification Mini-Language

並注意浮點問題(例如,請參閱answer to this question