numpy 将文本文件导出到Pandas

xqkwcwgp  于 2022-11-10  发布在  其他
关注(0)|答案(2)|浏览(179)
,100440001,5.4223240E-03,0.0000000E+00,9.5142264E-05,-1.6846368E-06,-1.6727865E-03,-3.5820480E-05,

,100440002,5.4231864E-03,-3.5126557E-05,1.7357473E-03,-8.8694117E-06,-1.6764278E-03,-3.1980174E-05,

,100440003,5.4183852E-03,-6.6414255E-05,3.3785363E-03,-1.9082331E-05,-1.6818597E-03,-2.7734946E-05,

,100440004,5.4019716E-03,-9.3277219E-05,5.0285659E-03,-2.6789506E-05,-1.6775288E-03,-2.3428154E-05,

,100440005,5.3782800E-03,-1.1620488E-04,6.6671266E-03,-3.5024775E-05,-1.6730428E-03,-2.0065860E-05,

,100440006,5.3434499E-03,-1.3648158E-04,8.3032505E-03,-4.1388424E-05,-1.6595235E-03,-1.8468531E-05,

,100440007,5.3042150E-03,-1.5528464E-04,9.9208083E-03,-4.7619368E-05,-1.6499927E-03,-1.7274167E-05,

,100440008,5.2545296E-03,-1.7329156E-04,1.1532459E-02,-5.3200382E-05,-1.6321282E-03,-1.7011654E-05,

,100440009,5.2003424E-03,-1.9090019E-04,1.3120634E-02,-5.8649741E-05,-1.6177379E-03,-1.6518644E-05,

,100440010,5.1361942E-03,-2.0826934E-04,1.4699071E-02,-6.4123893E-05,-1.5961040E-03,-1.6557273E-05,

,100440011,5.0667241E-03,-2.2552290E-04,1.6249184E-02,-6.9267478E-05,-1.5761539E-03,-1.6321806E-05,

,100440012,4.9883180E-03,-2.4265505E-04,1.7785292E-02,-7.4745884E-05,-1.5511048E-03,-1.6298149E-05,

,100440013,4.9034371E-03,-2.5969812E-04,1.9288632E-02,-7.9735148E-05,-1.5254069E-03,-1.6189753E-05,

,100440014,4.8108122E-03,-2.7658709E-04,2.0773313E-02,-8.5170787E-05,-1.4969780E-03,-1.5965583E-05,

,100440015,4.7105420E-03,-2.9331884E-04,2.2221114E-02,-9.0040440E-05,-1.4655895E-03,-1.5931278E-05,

,100440016,4.6036249E-03,-3.0979610E-04,2.3645303E-02,-9.5325104E-05,-1.4336460E-03,-1.5445142E-05,

,100440017,4.4881038E-03,-3.2599053E-04,2.5028789E-02,-1.0006818E-04,-1.3968052E-03,-1.5421975E-05,

我想用逗号分隔数字,并将每个数字放在单独的列中。然后我想把它们保存到EXCEL文件中。

jucafojl

jucafojl1#

如果是.txt文件,可以加载,然后转换成EXCEL文件,如下所示:

df = pd.read_table('file.txt')
df.to_excel(filepath)

文件路径:计算机中要存储文件的位置,如'C:/Downloads/newfile.xlsx'

yzuktlbb

yzuktlbb2#

逗号分隔的文件是CSV文件。需要使用pandas.read_csv命令,如下所示:

import pandas as pd
df = pd.read_csv('filename.CSV')

这将产生df,该df将成为您的数据的 Dataframe
然后可以导出到Excel:

df.to_excel('newfilename.XLSX')

相关问题