弯曲两个CSV文件的排序合并 [英] Gnuplotting the sorted merge of two CSV files

查看:76
本文介绍了弯曲两个CSV文件的排序合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图跳过前8行对两个CSV文件进行合并和排序.

我尝试按我使用的第36列对文件之一进行排序:

awk '(NR>8 ){print; }' Hight_5x5.csv | sort -nk36

并合并两个文件:

cat Hight_5x5.csv <(tail +8 Hight_5x5_b.csv)

sort命令不起作用.

我想两个在命令中同时使用两个动作,然后将结果发送到gnuplot的plot命令.我已经尝试过这一行:

awk '(NR>8 ){print; }' (cat Hight_5x5.csv <(tail +8 Hight_5x5_b.csv)) | sort -nk36

它确实合并了两个文件,但是它没有按列36排序,因此我认为在gnuplot plot命令中也无法使用.

plot "<awk '(NR>8 ){print; }' (cat Hight_5x5.csv <(tail +8 Hight_5x5_b.csv)) | sort -nk36"

问题是两个文件的格式.数据具有","分隔.例如,...,"0.041","3.5","40","false","1000","1.3","20","5","5","-20","2","100000000","0.8",....

链接具有两个CSV文件. /p>

致谢

解决方案

$ awk 'FNR>8' file1 file2 | sort -k36n 

应该可以,我想您也应该可以通过管道连接到gnuplot.

不了解您的评论,sort将进行排序.也许您没有36个字段,或者分隔符不是必须指定的空白.

这是一个带有逗号分隔字段的虚拟数据示例

$ awk 'FNR>3' <(seq 20 | paste - - -d,) <(seq 10 | shuf | paste - - -d,) | sort -t, -k2n
5,1
2,7
7,8
9,10
11,12
13,14
15,16
17,18
19,20

I am trying to merge and sort two CSV files skipping the first 8 rows.

I try to sort one of the files by the 36th column I use:

awk '(NR>8 ){print; }' Hight_5x5.csv | sort -nk36

and to merge the two files:

cat Hight_5x5.csv <(tail +8 Hight_5x5_b.csv)

The sort command it does not work.

I would like two use both actions in a command and send the result to the plot command of gnuplot. I have tried this line:

awk '(NR>8 ){print; }' (cat Hight_5x5.csv <(tail +8 Hight_5x5_b.csv)) | sort -nk36

and it does merge the two files but it does not sort by column 36, thus I assume in gnuplot plot command will not work too.

plot "<awk '(NR>8 ){print; }' (cat Hight_5x5.csv <(tail +8 Hight_5x5_b.csv)) | sort -nk36"

The problem is the format of the two files. The data have "," separations. For example, ...,"0.041","3.5","40","false","1000","1.3","20","5","5","-20","2","100000000","0.8",....

This link has the two CSV files.

Regards

解决方案

$ awk 'FNR>8' file1 file2 | sort -k36n 

should do, I guess you should be able to pipe to gnuplot as well.

Don't understand your comment, sort will sort. Perhaps you don't have 36 fields or your separator is not white space, which you have to specify.

Here is an example with dummy data with comma separated fields

$ awk 'FNR>3' <(seq 20 | paste - - -d,) <(seq 10 | shuf | paste - - -d,) | sort -t, -k2n
5,1
2,7
7,8
9,10
11,12
13,14
15,16
17,18
19,20

这篇关于弯曲两个CSV文件的排序合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆