如何提取txt文件中的数据到excel表格里面?谢谢!

sh/bash/dash/ksh/zsh等Shell脚本
回复
holddreams
帖子: 198
注册时间: 2007-05-06 0:53

如何提取txt文件中的数据到excel表格里面?谢谢!

#1

帖子 holddreams » 2014-03-17 16:51

有n个txt文件file1, file2, file3,....filen
其中每个file里面有m行,每行就一个数据或者字母,
现在想把这n个txt文件中的内容抓到excel表格里面,请问有相关的脚本吗?

比如,
file1中
a
b
c
file2中
d
e
f
file3中
g
h
i
要把这3个file中的数据分别提取出来,放到excel中的第1列,第2列,第3列,有什么简单办法?
谢谢!
头像
oneleaf
论坛管理员
帖子: 10455
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 如何提取txt文件中的数据到excel表格里面?谢谢!

#2

帖子 oneleaf » 2014-03-17 17:13

使用 awk 转 csv 文件
谢宝良
帖子: 1983
注册时间: 2010-05-01 21:23

Re: 如何提取txt文件中的数据到excel表格里面?谢谢!

#3

帖子 谢宝良 » 2014-03-17 23:14

很多办法的。
如果不懂脚本或者宏的话,可以这样操作:

一、先在每行的末尾添加一个字符,比如1,再整成为一行的数据,
然后合并到一个文件里,并且变成:
a1b1c1
d1e1f1
g1h1i1

二、复制到excel里,使用选择性粘贴,以1为分隔符分裂成多行数据即可。
附件
抓图52.png
抓图51.png
aerofox
帖子: 1453
注册时间: 2008-05-24 8:30

Re: 如何提取txt文件中的数据到excel表格里面?谢谢!

#4

帖子 aerofox » 2014-03-24 21:27

代码: 全选

paste file1 file2 file3 > fileall.csv
再用 excel 打开 fileall.csv
回复