Python在Apache OpenOffice中打开和保存csv文件

问题描述

我想知道有什么解决办法 1)使用python启动apache开放办公室 2)打开一个CSV文件 3)自动填写文字导入 4)然后将其保存到xls文件中。

import subprocess
subprocess.Popen('C:\Program Files (x86)\OpenOffice 4\program\soffice.exe')

解决方法

不确定为什么要使用Python打开OpenOffice。但是您可以使用pandas库读取csv并将其转换为excel文件。

import pandas as pd

read_file = pd.read_csv (r'Path where the CSV file is stored\File name.csv')
read_file.to_excel (r'Path to store the Excel file\File name.xlsx',index = None,header=True)