We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
This post was edited and submitted for review 2 years ago and failed to reopen the post:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
如果 URL列格式是统一的:在
'/'
上拆分,然后采取第三个项目;将其分配在'。'
上,然后采取第一个项目。If the url column format is uniform: Split on
'/'
and take the third item; split that on'.'
and take the first item.在应用真实数据之前,请务必针对测试目录进行验证。
假设您的.CSV文件具有标头行,并且每个数据行都遵循您指示的模式,请进行逗号分隔(请进行测试的原始数据),则
dir
在目录中找到所有.csv文件。在转动。下一个针对的然后在
%% e
中分析该行,并将%% q
设置为// 在
。
之前(假设/
和。
仅出现在第3列中)。echo
仅在分配%% Q
时执行,因此不在标题行上(s),header
将设置为< em>什么都没有,并且变得不确定。如果找不到数据线,则该行必须是标头,因此使用第四列标题输出该行。
最后,将数据收集到临时文件并移至原始文件。
我会再说一遍,
在应用于实际数据之前,请始终验证测试目录。
Always verify against a test directory before applying to real data.
Assuming your .csv files have a header line and each data line follows the pattern you indicate, comma-separated (raw data for testing, please) then
The
dir
finds all of the .csv files in the directory.header
is set toy
to indicate that a header line is expected, and then each line of the specified file is assigned to%%e
in turn. the nextfor
then analyses the line in%%e
and sets%%q
to the string after the//
and before the.
(assuming that/
and.
only occur in column3). Theecho
will only be executed if%%q
is assigned, so not on header line(s), andheader
will be set to nothing and become undefined.If no data line has been found, then the line must be a header, so output that line with the fourth column header.
Finally, the data is gathered to a temporary file and moved over the original.
I'll say again,
Always verify against a test directory before applying to real data.