[英]I have a csv file with two different formats of date value, want them to be in any single format
My CSV file looks like this 我的CSV文件如下所示
id date
1602 11/23/2015 14:10
1602 11/23/2015 22:45
1602 18/10/2011 09:19:46 AM
1702 18/10/2011 09:07:33 AM
1863 18/10/2011 09:07:35 AM
1436 18/10/2011 09:07:36 AM
I'm looking for output like 我正在寻找类似的输出
id date
1602 11/23/2015 14:10
1602 11/23/2015 22:45
1602 10/18/2011 09:19:46 AM
1702 10/18/2011 09:07:33 AM
1863 10/18/2011 09:07:35 AM
1436 10/18/2011 09:07:36 AM
I'm not sure why you are making this so much more difficult than it is. 我不确定为什么您要比现在做起来困难得多。 It seems that all you are actually doing is (1) getting rid of the first line of the CSV file;
看来您实际要做的只是(1)删除CSV文件的第一行; (2) tossing out any quotation marks;
(2)扔掉任何引号; (3) mapping sets of spaces/tabs into single spaces;
(3)将空格/制表符集映射为单个空格; and (4) mapping newlines to spaces.
(4)将换行符映射到空格。
SO . 所以 .
。 .
。 how about the following?
接下来呢? (I assume the data comes from standard input.)
(我假设数据来自标准输入。)
sed 1d | sed 1天| tr -d /\\"/ | tr -s "/[ \\010\\012]/ /"
tr -d / \\“ / | tr -s” / [\\ 010 \\ 012] / /“
The 'sed' deletes the first line; “ sed”删除第一行; the first 'tr' strips quotation marks;
第一个'tr'去除引号; the second 'tr' maps runs of spaces, tabs, and/or newlines to single spaces (\\010 and \\012 are the octal codes for ASCII TAB and ASCII NL, respectively).
第二个'tr'将空格,制表符和/或换行符映射到单个空格(\\ 010和\\ 012分别是ASCII TAB和ASCII NL的八进制代码)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.