データをExcelにフォーマットする[閉じる]

データをExcelにフォーマットする[閉じる]

txtファイルには、次の形式の大量のデータがあります。ご覧のとおり、各行にはヘッダーとパスがあります。ここで必要なのは、Excelのタイトル:パスなど、データを隣に表示する必要があることです。

誰でもこの問題を助けることができますか?

現在の結果

Title:Projects and Ideas
Path:/content/en_us/
Title:buying-guide
Path:/content/en_us/buying-guide
Title:Choose Exterior Paint Colors
Path:/content/en_us/buying-guide/choose-exterior-paint-colors
Title:Water Softener Buying Guide
Path:/content/en_us/buying-guide/water-softener-buying-guide
Title:Presentation Page
Path:/content/en_us/buying-guide/presentation-page

予想される結果

Title:Projects and Ideas       Path:/content/en_us/
Title:buying-guide        Path:/content/en_us/buying-guide
Title:Choose Exterior Paint Colors Path:/content/en_us/buyingguide/choose
Title:Water Softener Buying Guide  Path:/content/en_us/buying-guide/water
Title:Presentation Page      Path:/content/en_us/buying-guide/presentation-page

ベストアンサー1

ファイルタブを分割してテーブルに貼り付けたいとします。だからあなたはこれを行うことができます:

$ sed 'N;s/\n\(Path.*\)$/\t\1/' file
Title:Projects and Ideas    Path:/content/en_us/
Title:buying-guide  Path:/content/en_us/buying-guide
Title:Choose Exterior Paint Colors  Path:/content/en_us/buying-guide/choose-exterior-paint-colors
Title:Water Softener Buying Guide   Path:/content/en_us/buying-guide/water-softener-buying-guide
Title:Presentation Page Path:/content/en_us/buying-guide/presentation-page

ExcelはUnix / Linuxではありませんが、LibreOfiice CalcなどのLinuxで利用可能なオフィスソフトウェアにも同じ質問が適用されるため、私の答えです。

おすすめ記事