简体   繁体   English

将txt文件转换为CSV吗? -在Linux服务器上

[英]Convert txt file to CSV? - On a Linux Server

I want to set up a scheduled task on my website which is hosted on a linux server. 我想在Linux服务器上托管的网站上设置计划任务。 This task should download this txt file and convert it to CSV. 此任务应下载此txt文件并将其转换为CSV。

You can see that the txt file looks like a CSV file. 您可以看到txt文件看起来像CSV文件。 But it is just written in txt.. So, I have to convert it... 但这只是用txt编写的。所以,我必须将其转换...

I tried it local on my Mac and renamed it. 我在Mac上在本地尝试过,并将其重命名。 It works. 有用。 But If I say wget and save the txt file as csv file, I get a destroyed file. 但是,如果我说wget并将txt文件另存为csv文件,则会得到一个损坏的文件。

So, which way is the best way to do that? 那么,哪种方法是最好的方法呢?

Greetings and Thank You! 问候和谢谢!

It's not a CSV file but a TSV file, you can download and convert it like so: 它不是CSV文件,而是TSV文件,您可以像这样下载和转换它:

curl -s https://www.cdkeys.com/feeds/cdkeys_affiliate_feed_eur.txt | tr "\t" "," > output.csv

Or if you want the format that excel likes by default, iirc you need to use a semicolon instead of a comma (so substitute the "," with a ";" ) 或者,如果您想要excel默认喜欢的格式,iirc则需要使用分号而不是逗号(因此用";"代替"," ";"

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

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