当文件没有标题行时,如何使用 Import-CSV 导入制表符分隔的文本文件?

2024-04-10

我有一个巨大的文本文件(大约 500 MB),以制表符分隔。它不包含标头。所以它看起来像:

20140711   IBM   29.9068    [email protected] /cdn-cgi/l/email-protection    this is interesting
20140712   HP   2.3000    [email protected] /cdn-cgi/l/email-protection    this is interesting
20140713   GOOGLE   44.9033    [email protected] /cdn-cgi/l/email-protection    this is interesting
20140714   HTC   739.70    [email protected] /cdn-cgi/l/email-protection    this is interesting
20140715   SAMSUNG   8.442    [email protected] /cdn-cgi/l/email-protection    this is interesting
20140716   MICROSOFT   67.104    [email protected] /cdn-cgi/l/email-protection    this is interesting
20140717   DELL   5.0823    [email protected] /cdn-cgi/l/email-protection    this is interesting
...
...
...

我需要使用 Powershell 将文本作为表加载到 SQL Server 数据库中。由于文本文件中没有标题,因此“Import-Csv”cmdlet 输出的内容不正确。我认为它总是将第一行视为标题。

“Import-Csv”如何输出文本文件中的任何内容并忘记标头配置?

Thanks.


你可以试试这个:

$data = Import-Csv C:\temp\F.csv -Header "date","company","value","mail","description" -Delimiter "`t"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

当文件没有标题行时,如何使用 Import-CSV 导入制表符分隔的文本文件? 的相关文章

随机推荐