简体   繁体   English

Bash-如何在写入csv时跳过一列

[英]Bash - How to skip a column while writing to csv

In the following screenshot as you can see on the first row, there are country codes and for each country code with have two different related columns (MT & MO). 在第一行的以下屏幕截图中,有国家代码,并且每个国家代码都有两个不同的相关列(MT&MO)。 how do I skip adding a empty column after each country using bash script? 如何在每个国家/地区使用bash脚本后跳过添加空白列?

在此处输入图片说明

Here is how I write the countries row: 这是我写国家行的方式:

echo "'SG',,'ID',,'AU',,'MY',," >> ${fileName}

as you can see there are ,, in between the country codes to facilitate the reading the output but is there any way to skip adding column to end up having the whole column for each country? 如您所见,在国家/地区代码之间有,以方便读取输出,但是是否有任何方法可以跳过添加列以最终得到每个国家/地区的整个列呢? I need something like this: 我需要这样的东西:

在此处输入图片说明

Please advice, 请指教,

The CSV format does not provide any way to indicate that a cell spans several columns. CSV格式没有提供任何方式指示单元格跨越几列。 In fact, it doesn't provide any way to indicate formatting of any kind. 实际上,它没有提供任何方式来指示任何格式。

So if you are restricted to using CSV, you cannot do better than inserting an empty cell. 因此,如果限制使用CSV,则不能做的比插入一个空白单元格更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM