我在excel中也有以下数据(也有txt):
TEST K-0008 "Production TEST" 0 4016 8.6 0.01
TEST K-0009 "Production TEST" 0 4803 8.6 0.01
TEST K-0010 "Production TEST" 0 4803 8.6 0.01
以及如何使用excel-vba或awk(可以是其他格式)格式化下面的内容,感谢您的帮助?
TEST K-0008 "Production TEST"
0 8.6 0.01
4016
TEST K-0009 "Production TEST"
0 8.6 0.01
4803
TEST K-0010 "Production TEST"
0 8.6 0.01
4803
谢谢, S
答案 0 :(得分:0)
使用AWK的一种简单方法是(假设您的文件是data.txt)
awk '$1 "\t" $2 "\t" $3 "\n" $4 "\t" $6 "\t" $7 "\n" $5' data.txt
答案 1 :(得分:0)
var timezone = "GMT";
var timestamp_format = "k:mm"; // Timestamp Format.
var datestamp_format = "d/M";
var sheet = event.source.getSheetByName('My sheet'); //Name of the sheet where you want to run this script.
var questionArray = ['drink 1', 'drink 2', 'drink 3','drink 4', 'drink 5', 'drink 6','drink 7', 'drink 8', 'drink 9','drink 10', 'drink 11', 'drink 12','drink 13','drink 14'];
var responseArray = ['Timestamp 1', 'Timestamp 2', 'Timestamp 3', 'Timestamp 4', 'Timestamp 5', 'Timestamp 6', 'Timestamp 7', 'Timestamp 8','Timestamp 9','Timestamp 10','Timestamp 11', 'Timestamp 12', 'Timestamp 13', 'Timestamp 14'];
var actRng = event.source.getActiveRange();
var editColumn = actRng.getColumn();
var index = actRng.getRow();
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();//get values and place them inside array
var dateCol = headers[0].indexOf(timeStampColName); //get index position inside the array
for(var i = 0; i < questionArray.length ; i ++){
if (headers[0].indexOf(responseArray[1]) > -1 && index > 1 && editColumn == (headers[0].indexOf(questionArray[i])+1) ) { // only timestamp if 'Last Updated' header exists, but not in the header row itself!
var cell = sheet.getRange(index, (headers[0].indexOf(responseArray[i])+1) );
var date = Utilities.formatDate(new Date(), timezone, timestamp_format);
cell.setValue(date);
}
}
您遇到的问题是生产测试文本周围的引号。您可以使用awk,但可以使用引号作为分隔符。然后,您可以将第三个分隔的字段进一步拆分为一个数组以更改顺序。