Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution to the problem of garbled codes in cvs files under linux opened by execl

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

I haven't written an article for a long time. Today, I encountered a problem that execl opened the cvs file under linux. By the way, record the solution to the problem. Very often, you need to write some scripts to export sql reports on a regular basis. The exported files cannot be opened directly with execl or open with Chinese garbled codes. It can be solved in the following two steps:

First, deal with the format problem

Convert tab key or space to a comma

Convert the tab key to spaces in the shell script

Sed-I "s /\ tAccorde dagger g" table.csv

II. Code conversion

UTF-8 conversion GBK

Iconv-f TUF-8-t GBK table.csv-o newtable.csv

It's as simple as that, different environments, format conversion and transcoding are also different. But know the principle on it, csv files are separated by commas by default, the default is UTF-8 coding, if the file contains Chinese, you need to support the corresponding Chinese coding.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report