org将csv文件转换成table

时间:2021-03-27 17:53:04

导入csv文件

org-table-import命令,然后选择csv文件


文本转换

其实很简单,只需要将csv文件复制过来,然后用命令

C-u C-c |

现在举个例子,从网站https://archive.ics.uci.edu/ml/datasets/Iris下载csv文件

http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data

这是一个植物分类的csv文件,根据花萼和花瓣的长度和宽度,识别出鸢尾花的三种品类。

将csv内容复制到org文件中,然后运行上面的命令,会转换成org table,然后加上caption和head,会变成这样

#+caption: 鸢尾花识别| Sepal Length | Sepal Width | Petal Length | Petal Width | class           ||--------------+-------------+--------------+-------------+-----------------||          5.1 |         3.5 |          1.4 |         0.2 | Iris-setosa     ||          4.9 |         3.0 |          1.4 |         0.2 | Iris-setosa     ||          4.7 |         3.2 |          1.3 |         0.2 | Iris-setosa     ||          4.6 |         3.1 |          1.5 |         0.2 | Iris-setosa     ||          5.0 |         3.6 |          1.4 |         0.2 | Iris-setosa     ||          5.4 |         3.9 |          1.7 |         0.4 | Iris-setosa     ||          4.6 |         3.4 |          1.4 |         0.3 | Iris-setosa     ||          5.0 |         3.4 |          1.5 |         0.2 | Iris-setosa     ||          4.4 |         2.9 |          1.4 |         0.2 | Iris-setosa     ||          4.9 |         3.1 |          1.5 |         0.1 | Iris-setosa     ||          5.4 |         3.7 |          1.5 |         0.2 | Iris-setosa     ||          4.8 |         3.4 |          1.6 |         0.2 | Iris-setosa     ||          4.8 |         3.0 |          1.4 |         0.1 | Iris-setosa     ||          4.3 |         3.0 |          1.1 |         0.1 | Iris-setosa     ||          5.8 |         4.0 |          1.2 |         0.2 | Iris-setosa     ||          5.7 |         4.4 |          1.5 |         0.4 | Iris-setosa     ||          5.4 |         3.9 |          1.3 |         0.4 | Iris-setosa     |