フランスの文字列をMicrosoft Excelファイルにエクスポートするには?

フランスの文字列をMicrosoft Excelファイルにエクスポートするには?

Str.rcフランス語用の文字列ファイルは次のとおりです。

ID_STR_BRIGHTNESS;,"Luminosité"
ID_STR_CHILE_EASTER_ISLAND;,"Île de Pâques"
ID_STR_CURRENT_CH;,"Saisie chaîne"
ID_STR_DETAILS;,"Détails"

...

Str.xlsこれで、次のようにMicrosoftにエクスポートできます。

cat ./Str.rc | sed 's/.*,//g' > ./Str.xls

しかし、このように「詳細」から「詳細」を得ることができます。

ところで、コマンドエンコーディング形式でStr.rcファイルを取得しようとしましたが、enca Str.rc次のように返されました。

enca: Cannot determine (or understand) your language preferences.
Please use `-L language', or `-L none' if your language is not supported
(only a few multibyte encodings can be recognized then).
Run `enca --list languages' to get a list of supported languages.

それではどうすればいいですか?

ベストアンサー1

エンコードを正しく処理するようにUnixツールを調整できます。ただし、Pythonを使用して「、」の前のデータのみを削除したい場合:

with open('Str.xls', 'w') as ofp:
   with open('Str.rc') as fp:
       for line in fp:
           ofp.write(line.split(',',1)[1])

最初にファイルに保存せずにコマンドラインから実行するには、次のものを切り取り、貼り付けることができます。

python -c "with open('Str.xls', 'w') as ofp:
    with open('Str.rc') as fp:
       for line in fp:
           ofp.write(line.split(',',1)[1])"

おすすめ記事